#include <fstream>
#include <iostream>
#include <cmath>
#include <queue>
#include <string>

using namespace std;

string binary(int input)
{
    string output="";
    if (input==0) return "000000000000000000000000000000";
    for (;;)
    {
        if (input==1) break;
        else if (input%2==1) output="1"+output;
        else output="0"+output;
        input/=2;
    }
    output="1"+output;
    int temp=output.length();
    for (int i=1;i<=(30-temp);i++) output="0"+output;
    return output;
}
int main()
{
    ifstream fin("DATA5.txt");
    ofstream fout("OUT5.txt");
    int a,b;
    string c;
    bool temp;
    for (int t=0;t<5;t++)
    {
        temp=true;
        fin>>a>>b;
        //cout<<a<<" "<<b<<endl;
        c=binary(b);
        for(int i=30-a;i<=29;i++){
            if(c[i]=='0') temp=false;
        }
        //cout<<c<<endl;
        if(temp==false) fout<<"OFF"<<endl;
        else fout<<"ON"<<endl;
    }
    return 0;
}


