Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

A. Subtractions

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou'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.

Examples

Input

2

4 17

7 987654321

Output

8

141093479

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/16/2018 15:08:47 (d2).

Desktop version, switch to mobile version.

User lists

Name |
---|