Task
Alex is passionate about diverse mathematical challenges, and as a gift for you to start the new IIOT season, he gives you three positive integers , and . He tells you that you must use exactly increments (i.e., increasing a value by one) on and , in any way you want. Now, he wants to find the greatest possible value of the greatest common divisor of the two integers obtained after the increments.
For example, if , and , the answer is , because we can use all increments on to make it equal to and . However, if , and , the answer is (, after incrementing the values times).
Alex decided to test you on such triplets. Show Alex that math is your friend as well!
Input data
The first line contains , the number of test cases. Each of the next lines contains three positive integers, , , and .
Output data
You need to write lines, each line containing the answer for the corresponding triple of values.
Constraints and clarifications
# | Points | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 30 | |
3 | 70 | No additional constraints |
Example
stdin
4
7 11 3
18 9 3
58 38 14
68 94 231
stdout
7
10
22
131
Explanation
The first two triples of the sample case were explained in the statement. For the third triple, you can increment the numbers to and , respectively. For the last triple, you can increment the numbers to and , respectively. It can be proved that these values are optimal.