Under construction

Still being built. Things may change

Snapper Chain (Small)

Interview

Time limit5sMemory limit512 MB

Summary
Decide whether N chained toggle switches all turn on after K snaps, which lights the bulb.
Level

Easy3 of 10

Topics
Bit manipulation, Simulation
Solved
No attempts yet

Problem

A Snapper is a small electrical device with an input plug on one side and an output socket on the other. The output socket takes a device such as a light bulb, or the input plug of another Snapper.

A Snapper is either ON or OFF. Power leaves the output socket only while the Snapper is ON and its input plug is receiving power. When you snap your fingers, every Snapper that is receiving power at that moment swaps ON for OFF and OFF for ON.

One day I bought NN Snappers, plugged the first one into a wall power socket, plugged the second one into the output socket of the first, and kept going that way down the chain. Then I attached a light bulb to the output socket of the NN-th Snapper.

At the start every Snapper is OFF, only the first one receives power, and the bulb is dark. After one snap the first Snapper turns ON and power reaches the second Snapper. After a second snap the first and the second Snapper both flip, so the second one is ON but receives no power. The third snap flips only the first Snapper, so the first and the second are both ON. Had a bulb been attached to the output socket of the second Snapper, it would light up.

I kept snapping for hours. Decide whether the bulb is lit after KK snaps. The bulb is an ordinary one with no tricks, so it lights only while the Snapper directly in front of it supplies power.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains two integers NN and KK.

Constraints

  • 1≤T≤50001 \le T \le 5000
  • 1≤N≤101 \le N \le 10
  • 0≤K≤1000 \le K \le 100

Output

For each test case print one line in the form Case #X: Y. Here XX is the test case number starting from 1, and YY is ON if the bulb is lit and OFF if it is dark.

Examples2

  1. Example 1

    Input
    4
    1 0
    1 1
    4 0
    4 47
    
    Expected output
    Case #1: OFF
    Case #2: ON
    Case #3: OFF
    Case #4: ON
    
  2. Example 2

    Input
    6
    1 0
    1 1
    1 2
    1 3
    1 4
    1 5
    
    Expected output
    Case #1: OFF
    Case #2: ON
    Case #3: OFF
    Case #4: ON
    Case #5: OFF
    Case #6: ON