Alice is in love with remainders. His friend Bob gifted her the number \(R\).
A function \(F(X)\) is defined as the number of possible pairs \((A,B)\) such that the following conditions are satisfied:
- \(A\) and \(B\) are positive integers less than or equal to \(N\).
- \(A\%B\), the remainder when \(A\) is divided by \(B\), is greater than or equal to \(X\).
Find the maximum possible non-negative integer \(Y\), such that \(F(Y)\) is greater than or equal to \(R\). If it is impossible to find such an integer, print \(-1\).
Input Format
- The first line contains an integer \(T\), which denotes the number of test cases.
- The first line of each test case contains two integers, \(N\) and \(R\).
Output Format
For each test case, print \(Y\), the maximum possible non-negative integer such that \(F(Y)\) is greater than or equal to \(R\). If it is impossible to find such an integer, return \(-1\).
Constraints
\(1 \leq T \leq 10 \\ 1 \leq N \leq 10^5 \\ 1 \leq R \leq 10^9\)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial