Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Game of Shells

By KIRIN29 · 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

Input will contain T (<=10^5) the number of test cases.

T lines will follow each having two integers P, Q (1 <= P, Q <= 10^16); where P denotes the number of shells Klee found and Q 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

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

See sample for better understanding.

Samples

InputOutput
1
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

InputOutput
1
3 2
Case #1: Jean

    Discussion

    Statistics


    54% Solution Ratio

    SyedaSohiEarliest, 3w ago

    prodip_bsmrstuFastest, 0.0s

    akash740Lightest, 1.8 MB

    user.221341Shortest, 168B

    Submit

    Login to submit

    Toph uses cookies. By continuing you agree to our Cookie Policy.