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

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.

msriramvarma01 | 25 |

AbhilashKumar2 | 24 |

monusinghal | 24 |

tripurari_IT | 24 |

Abreez Das | 23 |

ARUN_PUNDIR | 609 |

manishgupta8497 | 607 |

KhyatiSoneji | 501 |

Abhimanyu_kumar | 487 |

vvggfggcg | 453 |

blackshadows | 5333 |

Ibrahim Nash | 5221 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.