Gru wants to distribute $N$ bananas to $K$ minions on his birthday.
Gru does not like to just give everyone the same number of bananas, so instead, he wants to distribute bananas in such a way that each minion gets a $distinct$ amount of bananas. That is, no two minions should get the same number of bananas.
Gru also loves $gcd$. The higher the $gcd$, the happier Gru and the minions get. So help Gru in distributing the bananas in such a way that each Minion gets a distinct amount of bananas and gcd of this distribution is highest possible. Output this maximum gcd. If such a distribution is not possible output $-1$.
Note: You have to distribute $all$ $N$ bananas. 
-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase consists of a single line of input, which has two integers: $N, K$. 
-----Output:-----
For each testcase, output in a single line the maximum gcd or -1.
-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq N, K \leq 10^9$
-----Sample Input:-----
1
6 3
-----Sample Output:-----
1
-----EXPLANATION:-----
The only possible distribution is $[1, 2, 3]$. So the answer is 1.
def factors(x):
 result = []
 i = 1
 while i*i <= x:
  if x % i == 0:
   result.append(i)
   if x//i != i:
    result.append(x//i)
  i += 1
 return result

t = int(input())
for _ in range(t):
 n, k = map(int, input().split())
 a = factors(n)
 an = -1
 for i in a:
  c = ((i*k*(k+1))//2)
  if (c%i==0 and c<=n):
   an=max(an,i)
 print(an)
def factors(x):
 result = []
 i = 1
 while i*i <= x:
  if x % i == 0:
   result.append(i)
   if x//i != i:
    result.append(x//i)
  i += 1
 return result

t = int(input())
for _ in range(t):
 n, k = map(int, input().split())
 a = factors(n)
 an = -1
 for i in a:
  c = ((i*k*(k+1))//2)
  if (c%i==0 and c<=n):
   an=max(an,i)
 print(an)