Repeating GCD
Submissions: 611   Accuracy:

28.01%

  Difficulty: Easy   Marks: 2

Given three  integers N, x and y, a number A is formed by repeating N x times and another number B is formed by repeating N y times. You need to find the GCD(A,B). 

Input
The first line of input contains of an integer 'T' denoting number of test cases
Only line of each test case contains three integers N,x and y .

Output
For each case print an integer corresponding to the answer .


Constraints
1<=T<=100
1<=N,x,y<=10^18

 

Example

Input
2
1 1 1
2 2 3

Output
1
2

Explanation
For 2nd test case 
A=22 B=222  gcd(A,B)=2

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Hardik Gulati
Author: hardikgulati96


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.