#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define fast ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
struct block
{
int l;
int r;
int tag;
}bol[1000];
int a[N], belong[N], b_size, num, n, m;
void build(int n)
{
b_size = sqrt(n);
num = n/b_size; if (num % b_size) num++;
for (int i = 1; i < num; i++)
{
bol[i].l = (i-1)*b_size + 1;
bol[i].r = i*b_size;
}
bol[num].l = (num-1)*b_size + 1;
bol[num].r = n;
for (int i = 1; i <= n; i++)
{
belong[i] = (i-1)/b_size + 1;
}
}
void pushdown(int x)
{
for (int i = bol[x].l; i <= bol[x].r; i++) a[i] ^= 1;
bol[x].tag = 0;
}
void change(int x, int y)
{
if (belong[x] == belong[y])
{
if (bol[belong[x]].tag) pushdown(belong[x]);
for (int i = x; i <= y; i++) a[i] ^= 1;
return;
}
if (bol[belong[x]].l != x)
{
if (bol[belong[x]].tag) pushdown(belong[x]);
for (int i = x; i <= bol[belong[x]].r; i++) a[i] ^= 1;
}else bol[belong[x]].tag ^= 1;
if (bol[belong[y]].r != y)
{
if (bol[belong[y]].tag) pushdown(belong[y]);
for (int i = bol[belong[y]].l; i <= y; i++) a[i] ^= 1;
}else bol[belong[y]].tag ^= 1;
for (int i = belong[x] + 1; i <= belong[y] - 1; i++) bol[i].tag ^= 1;
}
int query(int x)
{
return a[x]^bol[belong[x]].tag;
}
void solve()
{
cin >> n >> m;
build(n);
while (m--)
{
int f, x, y;
cin >> f;
if (f == 1)
{
cin >> x >> y;
change(x, y);
}
else if (f == 2)
{
cin >> x;
cout << query(x) << '\n';
}
}
}
signed main()
{
fast
int T = 1;
while (T--) solve();
}