/////////////////////////////////////////////////////////////////////////////
// Written in
//    ActionScript (using mtasc 1.14)
//    http://www.mtasc.org/
/////////////////////////////////////////////////////////////////////////////

class A
{
	static function main(mc)
	{
		var input_string = "<paste the input data here>";
		var input = input_string.split("\n");
		var T = Number(input[0]);

		var output_string = ""
		for(var C=1; C<=T; ++C)
		{
			var theCase = input[C].split(" ");
			var N = Number(theCase[0]);
			var K = Number(theCase[1]);
			output_string += "Case #" + C + ": " + (solve(N,K)?"ON":"OFF") + "\n"
		}

		_root.createTextField("tf",0,0,0,800,600);
		_root.tf.text = output_string;
	}

	static function solve(N, K)
	{
		var mask = (1<<N) - 1;
		return (K & mask) == mask;
	}
}
