Choosing Ice Cream

No attempts yetTime limit1sMemory limit256 MB

Problem

You are standing in a supermarket in front of the freezers, and you have to pick one of the nn kinds of ice cream for after dinner. After a while you give up, because they all look good. Instead you take a fair kk-sided die out of your pocket and let it decide for you.

The number of kinds, nn, need not equal kk, so you cannot always throw the die once, read the value ii, and take the iith kind. You need an algorithm that uses zero or more die throws and makes every kind exactly equally likely. The accept-reject method gives such a fair choice.

Then you remember the competition you have to attend that same afternoon. You cannot afford to be late for it. The accept-reject method has no bound on the number of throws it needs before it produces a fair result, so you could stand in front of the freezers for a long time and miss the competition. You therefore want a fair algorithm that uses as few throws as possible in the worst case.

Given nn and kk, determine the smallest number ii such that some fair algorithm uses at most ii die throws per execution.

Input

The first line contains one positive integer, the number of test cases. This value is at most 100.

Then, per test case:

  • one line with two space separated integers nn and kk (1n,k1091 \le n, k \le 10^9): the number of ice cream kinds and the number of sides of the die.

Output

Per test case:

  • one line with a single integer, the smallest number of throws after which a fair choice is guaranteed to be possible. If there is no such number, print unbounded instead.

Hint

For n=4n = 4 and k=20k = 20 one throw is enough.