Bathroom Stalls
A certain bathroom has n + 2 stalls in a single row; the stalls on the left and right ends are permanently occupied by the bathroom guards. The other n stalls are for users.
Whenever someone enters the bathroom, they try to choose a stall that is as far from other people as possible. To avoid confusion, they follow deterministic rules: For each empty stall s, they compute two values l[s]
and r[s]
, each of which is the number of empty stalls between s and the closest occupied stall to the left or right, respectively. Then they consider the set of stalls with the farthest closest neighbor, that is, those s for which min(l[s]
, r[s]
) is maximal. If there is only one such stall, they choose it; otherwise, they choose the one among those where max(l[s]
, r[s]
) is maximal. If there are still multiple tied stalls, they choose the leftmost stall among those.
k people are about to enter the bathroom; each one will choose their stall before the next arrives. Nobody will ever leave.
When the last person chooses their stall s, what will the values of max(l[s]
, r[s]
) and min(l[s]
, r[s]
) be?
Input
The first line gives the number of test cases t (1 ≤ t ≤ 100). t lines follow. Each line describes a test case with two integers n (1 ≤ n ≤ 10^18
) and k (1 ≤ k ≤ n) as described above.
Output
For each test case, output one line containing Case #x: y z, where x is the test case number (starting from 1), y is max(l[s]
, r[s]
), and z is min(l[s]
, r[s]
) as calculated by the last person to enter the bathroom for their chosen stall s.