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.

SumitSingh27 | 72 |

SanketAgarwal1 | 54 |

rathiarpit29 | 52 |

ujjwalsoni1999 | 52 |

vishalkumar61 | 50 |

SumitSingh27 | 398 |

saiujwal13083 | 279 |

ujjwalsoni1999 | 277 |

NaveenKumarNakka | 275 |

_maverick7_ | 266 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4931 |

Quandray | 4598 |

Login to report an issue on this page.