Problem: Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.
To improve his division skills, Oleg came up with pairs of integers and and for each pair decided to find the greatest integer , such that:
- is divisible by ;
- is not divisible by .
Input Format: The first line contains an integer () — the number of pairs.
Each of the following lines contains two integers and (; ) — the -th pair of integers.
Output Format: Print integers: the -th integer is the largest such that is divisible by , but is not divisible by .
One can show that there is always at least one value of satisfying the divisibility conditions for the given constraints.
Note: For the first pair, where and , the answer is , since it is the greatest divisor of and is not divisible by .
For the second pair, where and , note that
- is not a valid , since is divisible by ;
- is not valid as well: is also divisible by .