Limits 1s, 512 MB

Monstadt’s honorable knights are enjoying their summer vacation in a distant archipelago named Golden Apple. The youngest member of the group, Klee has found some sea shells and started playing with them. But eventually she got bored and thought of a game to play with others.

She called the acting grand master Jean to come and play with her. She will place a number of shells she found in the beach and she will take a certain amount of shells each turn. Then Jean will do the same. They will repeat the process until there is no shell remaining. The person to take the last shell will win the game. Klee will always go first and Jean will follow.


Input will contain TT (T105T \le 10^5) the number of test cases.

TT lines will follow each having two integers PP, QQ (1P,Q10161 \le P, Q \le 10^{16}); where PP denotes the number of shells Klee found and QQ denotes the maximum number of shells each person can pick at each turn.

One has to take at least one shell each turn and both Klee and Jean will play the game optimally.


Output as following: Case #x: (the name of the winner); where xx is the number of test case.


3 1
Case #1: Klee

There are three shells and one can pick one shell each turn. If they play optimally Klee will win as following steps

  1. Klee takes one shell, two shells remain.

  2. Jean takes one shell, one shell remain

  3. Klee takes the last shell and wins

3 2
Case #1: Jean


Login to submit.



58% Solution Ratio
SyedaSohiEarliest, Aug '21
steinumFastest, 0.0s
steinumLightest, 5.5 kB
user.221341Shortest, 168B
Toph uses cookies. By continuing you agree to our Cookie Policy.