Task
You are given three natural numbers, , , and . George, being passionate about mathematics and computer science, has invented an algorithm, and now he wants to test your computer science knowledge to find the answers he is looking for.
The algorithm described by George works as follows:
As long as and are different, print and on a new line and subtract the smaller number from the larger one.
For example, if initially and , the first pairs of displayed values are:
- (first pair)
- (subtract from )
- (subtract from )
- (subtract from )
- (subtract from )
Now, George wants to know what the values of and will be at the -th step.
Practically, if is , you should print .
Since this is too easy, he asks you to solve the problem for such triplets. He guarantees that the algorithm will display at least lines.
Input data
The first line of the input file operatii.in
will contain , the number of triplets for which you need to solve the problem.
The following lines contain the triplets, each containing , the three numbers of the triplet.
Output data
For each triplet, print on a separate line in the file operatii.out
the value of and the value of after steps.
Constraints and clarifications
- ;
- ;
- The algorithm will display at least lines.
- For tests worth points, and .
- For tests worth points, and .
Example
operatii.in
2
14 39 3
167 96 7
operatii.out
14 11
17 4
Explanation
For the first pair, the explanation is found in the statement.
For the second pair, the values of and change as follows:
We will print .