1392 -- Find Its Place
Time Limit :1000 MS Memory Limit :65536 KB
Accepts : 89 Submits : 232
User Accepts : 64 User Submits : 73
<Submit>   <Statistics>   <Discuss>

Description

Yang Hui’s triangle is known to all:
          1
        1  1
      1  2  1
    1  3  3  1
  1  4  6  4  1
1  5  10  10  5  1
In it the ends of each line is 1, and every other number in each line equals to the sum of the two numbers on the shoulders. It’s obvious that it’s a piece of cake (especially with the help of computer)for us to get value of number C in line R, therefore our problem goes to the opposite: given two Continuous numbers in a same line in this "triangle", please find out their positions.

Input

The first line of the input is a N indicating the test cases number.
Then follow N lines. Each line includes two positive integers: a, b, and a, b < 2^31. The number a should be aligned on the left of the number b. It’s certain that for every data input there is always a solution.
 

Output

For each testing data there will be only one line out: R C. which means number C on line R. What’s more, R and C should be separated by a blank space. For multiple solutions, please print out the solution with the minimum R.

Sample Input

3
1 2
3 3
10 5

Sample Output

3 1
4 2
6 4

 

Source

Alpc NUDT campus contest 2009
<Submit>   <Statistics>   <Discuss>
 


Powered by Zhang Zhaoning PDL College of Computer
Since 2006.03.09 | 2007.11.22 | 2010.03.02 Copyright (r) 2006 - 2010 All Rights Reserved