#include <iostream>
#include <fstream>
#include <bitset>

using namespace std;
int main() {
    ifstream in;
    in.open("DATA1.txt");
    ofstream out;
    out.open("OUT1.txt");
    int b;
    int a;
    for (int i=0; i<5; i++) {
        in >> a >> b;
        bitset<8> bits(a);
        out << bits[b] << endl;
    }
    in.close();
    out.close();
    //system("PAUSE");
    return 1000;
}

