#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main (){
	freopen ("data5.txt", "r", stdin);
	freopen ("out5.txt", "w", stdout);
	int z, i, a, n, t, k;
	int b[27];
	
	for (z=0; z<5; ++z){
		cin >> n >> k;
		a=26;
		t=67108864;
		while (a!=-1){
			if (k>=t){
				b[a]=1;
				k-=t;
			}
			else {
				b[a]=0;
			}
			t/=2;
			--a;
		}
		if (n>26){
			cout << "OFF" << endl;
		}
		else if (b[n-1]==1){
			cout << "ON" << endl;
		}
		else {
			cout << "OFF" << endl;
		}
	}
	
	return 0;
} 

