3736.Subtractions

Time Limit: 1s Memory Limit: 256MB

You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5).

You've got some number of pairs (ai,bi). How many operations will be performed for each of them?

Input Format(From the terminal/stdin)

The first line contains the number of pairs n (1 \le n \le 1000). Then follow n lines, each line contains a pair of positive integers ai,bi (1 \le ai,bi \le 109).

Output Format(To the terminal/stdout)

Print the sought number of operations for each pair on a single line.

Sample Input

Copy
2
4 17
7 987654321
 \n
 ·  \n
 ·         \n

Sample Output

Copy
8
141093479
 \n
         \n

Submit

请先 登录

© 2025 FAQs