As we know that sharing is a good policy, but Rohan's younger brother Ted is very mischievous. He is very fond of chocolates. But actually he can't reach to the height of the kitchen shelf, where 'N' chocolates are kept. So, he can call any number of family members from 1 to K. But there is a condition that when members come and reach out to shelf, they divide all the chocolates between them in such a way that everyone will get the same amount of chocolates and this amount is maximal possible. If chocolates are left, Ted can take them after they go. Since Ted is not so smart, you need to tell him how much maximum chocolates he will get if he call maximum of 'K' people.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains two space separated integers N and K.
For each test case in a new line output - the maximum possible number of chocolates Ted can get.
1 ≤ T ≤ 50
1 ≤ N, K ≤ 105
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.