/**
* Author: ZyadFVA
* --
**/
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
const int MOD = 1e9+7;
void solve()
{
int q,n;
cin>>q>>n;
while (q--)
{
int op,x;
cin>>op>>x;
if(op==1)
{
//shift n to right x times and make "AND" with 1.
cout << ((n>>x)&1) <<endl;
/*
* another sol
* int m = n;
* m>>=x; // shift right x times
* cout << (m&1)<<endl; // print bit value
*/
}
else if (op==2)
{
//shift 1 left x times and make "OR" with n;
n|= (1<<x);
cout << n<<endl;
/*
* another sol
* int m = 1<<x;
* n|=m;
*/
}
else if (op==3)
{
// shift 1 left x times, then make "NOT" operation on it so flip all bits
// then make "AND" with n;
n&= ~(1<<x);
cout << n<<endl;
/*
* another sol
* int m = 1<<x;
* m = ~m; // flip all bits so only x-th bit be zero
* n&=m;
*/
}
else
{
//shift 1 left x times and make "XOR" with n;
n^= (1<<x);
cout << n<<endl;
/*
* another sol
* int m = 1<<x;
* n^=m;
*/
}
}
}
int32_t main() {
ios::sync_with_stdio(false);
//freopen("output.txt","w", stdout);
cin.tie(nullptr);
int t = 1;
//cin >> t;
for (int i = 1; i <= t; ++i) {
solve();
}
return 0;
}
LyoqCiAqICAgIEF1dGhvcjogIFp5YWRGVkEKICogICAgLS0KKiovCgojaWZkZWYgTE9DQUwKCiNpbmNsdWRlICJhbGdvL2RlYnVnLmgiCgojZWxzZQojZGVmaW5lIGRlYnVnKC4uLikgNDIKI2VuZGlmCgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIGludCBsb25nIGxvbmcKY29uc3QgaW50IE1PRCA9IDFlOSs3OwoKCgp2b2lkIHNvbHZlKCkKewoKCiAgICBpbnQgcSxuOwogICAgY2luPj5xPj5uOwoKICAgIHdoaWxlIChxLS0pCiAgICB7CiAgICAgICAgaW50IG9wLHg7CiAgICAgICAgY2luPj5vcD4+eDsKICAgICAgICBpZihvcD09MSkKICAgICAgICB7CiAgICAgICAgICAgIC8vc2hpZnQgbiB0byByaWdodCB4IHRpbWVzIGFuZCBtYWtlICJBTkQiIHdpdGggMS4KICAgICAgICAgICAgY291dCA8PCAoKG4+PngpJjEpIDw8ZW5kbDsKICAgICAgICAgICAgLyoKICAgICAgICAgICAgICogYW5vdGhlciBzb2wKICAgICAgICAgICAgICogaW50IG0gPSBuOwogICAgICAgICAgICAgKiBtPj49eDsgLy8gc2hpZnQgcmlnaHQgeCB0aW1lcwogICAgICAgICAgICAgKiBjb3V0IDw8IChtJjEpPDxlbmRsOyAvLyBwcmludCBiaXQgdmFsdWUKICAgICAgICAgICAgICovCiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKG9wPT0yKQogICAgICAgIHsKICAgICAgICAgICAgLy9zaGlmdCAxIGxlZnQgeCB0aW1lcyBhbmQgbWFrZSAiT1IiIHdpdGggbjsKICAgICAgICAgICAgbnw9ICgxPDx4KTsKICAgICAgICAgICAgY291dCA8PCBuPDxlbmRsOwogICAgICAgICAgICAvKgogICAgICAgICAgICAgKiBhbm90aGVyIHNvbAogICAgICAgICAgICAgKiBpbnQgbSA9IDE8PHg7CiAgICAgICAgICAgICAqIG58PW07CiAgICAgICAgICAgICAqLwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChvcD09MykKICAgICAgICB7CiAgICAgICAgICAgIC8vIHNoaWZ0IDEgbGVmdCB4IHRpbWVzLCB0aGVuIG1ha2UgIk5PVCIgb3BlcmF0aW9uIG9uIGl0IHNvIGZsaXAgYWxsIGJpdHMKICAgICAgICAgICAgLy8gdGhlbiBtYWtlICJBTkQiIHdpdGggbjsKICAgICAgICAgICAgbiY9IH4oMTw8eCk7CiAgICAgICAgICAgIGNvdXQgPDwgbjw8ZW5kbDsKICAgICAgICAgICAgLyoKICAgICAgICAgICAgICogYW5vdGhlciBzb2wKICAgICAgICAgICAgICogaW50IG0gPSAxPDx4OwogICAgICAgICAgICAgKiBtID0gfm07IC8vIGZsaXAgYWxsIGJpdHMgc28gb25seSB4LXRoIGJpdCBiZSB6ZXJvCiAgICAgICAgICAgICAqIG4mPW07CiAgICAgICAgICAgICAqLwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICAvL3NoaWZ0IDEgbGVmdCB4IHRpbWVzIGFuZCBtYWtlICJYT1IiIHdpdGggbjsKICAgICAgICAgICAgbl49ICgxPDx4KTsKICAgICAgICAgICAgY291dCA8PCBuPDxlbmRsOwogICAgICAgICAgICAvKgogICAgICAgICAgICAgKiBhbm90aGVyIHNvbAogICAgICAgICAgICAgKiBpbnQgbSA9IDE8PHg7CiAgICAgICAgICAgICAqIG5ePW07CiAgICAgICAgICAgICAqLwogICAgICAgIH0KICAgIH0KCgp9CgppbnQzMl90IG1haW4oKSB7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICAvL2ZyZW9wZW4oIm91dHB1dC50eHQiLCJ3Iiwgc3Rkb3V0KTsKICAgIGNpbi50aWUobnVsbHB0cik7CiAgICBpbnQgdCA9IDE7CiAgICAvL2NpbiA+PiB0OwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gdDsgKytpKSB7CiAgICAgICAgc29sdmUoKTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQ==