https://codeforces.ml/contest/1445/problem/C
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 tt pairs of integers pipi and qiqi and for each pair decided to find the greatest integer xixi, such that:
- pipi is divisible by xixi;
- xixi is not divisible by qiqi.
Oleg is really good at division and managed to find all the answers quickly, how about you?
Input
The first line contains an integer tt (1≤t≤501≤t≤50) — the number of pairs.
Each of the following tt lines contains two integers pipi and qiqi (1≤pi≤10181≤pi≤1018; 2≤qi≤1092≤qi≤109) — the ii-th pair of integers.
Output
Print tt integers: the ii-th integer is the largest xixi such that pipi is divisible by xixi, but xixi is not divisible by qiqi.
One can show th