#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
int get_depth(const int &u) {
if (!u) return 0ll;
return 64ll - __builtin_clzll(u);
}
void Main() {
int n, m;
cin >> n >> m;
unordered_set<int> cut;
gp_hash_table<int, int> mp;
auto get_sz = [&](const int &u) {
const int &d = get_depth(u), &chk = n - d + 1;
if (chk <= 0) {
return 1ll;
}
return (1ll << chk) - 1ll;
};
auto f = [&](const int &u) {
const auto &it = mp.find(u);
if (it != mp.end()) {
return it->second;
}
return get_sz(u);
};
auto get_rt = [&](const int &u) {
int rt = u;
while (rt != 1) {
if (cut.contains(rt)) {
break;
}
rt >>= 1;
}
return rt;
};
int res = 0;
while (m--) {
int op, x;
cin >> op >> x;
if (op == 1) {
if (x == 1 || cut.contains(x)) {
continue;
}
cut.insert(x);
const int &a = f(x), p = x >> 1;
int nd = p;
while (nd) {
if (cut.contains(nd)) {
if (mp.find(nd) == mp.end()) {
mp[nd] = get_sz(nd);
}
mp[nd] -= a;
break;
}
if (mp.find(nd) == mp.end()) {
mp[nd] = get_sz(nd);
}
mp[nd] -= a;
if (nd == 1) {
break;
}
nd >>= 1;
}
} else if (op == 2) {
res ^= f(get_rt(x));
}
}
cout << res << endl;
}
// #define __CP_MULTI_TEST_CASES
signed main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t = 1;
#ifdef __CP_MULTI_TEST_CASES
cin >> t;
#endif
while (t--) {
Main();
}
return cout << flush, fflush(stdout), 0;
}