Codeforces Testing Round 5
A
Subtractions
Codeforces
900
原题
←B →
翻译中…

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 ($*a*_{*i*}, *b*_{*i*}$). How many operations will be performed for each of them?

翻译中…

Input

翻译中…

The first line contains the number of pairs $*n*$ ($1  ≤  *n*  ≤  1000$). Then follow $*n*$ lines, each line contains a pair of positive integers $*a*_{*i*}, *b*_{*i*}$ ($1  ≤  *a*_{*i*},  *b*_{*i*}  ≤  10^{9}$).

翻译中…

Output

翻译中…

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

翻译中…

样例

Input #1
2
4 17
7 987654321
Output #1
8
141093479
InputCopy OutputCopy
题目信息
题号
267A
时间限制
1 s
内存限制
256 MB
标签
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。