Alice and Bob are playing a game. Alice gives Bob an integer $$$k$$$. Then Bob picks another non-negative integer $$$n$$$ and performs some moves (possibly zero) on $$$n$$$. In one move, he does the following:
Input starts with an integer $$$T$$$ ($$$1\leq T\leq 10^5$$$), denoting the number of test cases.
Each of the next $$$T$$$ lines contain two integers $$$r$$$ ($$$0 \leq r \leq 10^{18}$$$) and $$$k$$$ ($$$2 \leq k \leq 10^{18}$$$).
For each test case, you have to print the maximum number of moves that can be performed among all $$$n$$$, such that $$$0 \leq n \leq r$$$.
2 5 2 4 3
4 3
In the first sample, we have $$$r=5$$$. So $$$n$$$ cannot be bigger than $$$5$$$.
If we choose $$$n = 5$$$, we get the maximum number of moves $$$=4$$$.
| Name |
|---|


