In the real world, Bob is solving a programming problem but he is stuck on it. He is given Q (1 ≤ Q ≤ 105) queries. Each query consists of two integers a and b (1 ≤ a,b ≤ 5*105). For each query, he is required to find the minimum non-negative integer c such that ac % b is 0 or ac is divisible by b. If no such c exists, the answer for that query is -1. Can you help him ?
Input:
First line consists of a single integer Q, the number of queries.
Q lines follow. Each line represents a query and consists of two space separated integers a and b, as described above.
Output:
Print Q lines. In the ith line, print the answer for ith query.
Constraints:
1 ≤ Q ≤ 105
1 ≤ a,b ≤ 5*105