#include<bits/stdc++.h>
using namespace std;
const int maxn=5*1e5+5;
int n,m;
int a[maxn],c[maxn];
int lowbit(int x) {
return x&(-x);
}
void updata(int i,int k) {
for(; i <= n; i += lowbit(i)) c[i] += k;
}
int getsum(int i) {
int res = 0;
for(; i>0; i -= lowbit(i)) res += c[i];
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n>>m;
int op,x,y;
for(int i=1;i<=m;i++){
cin>>op;
if(op==1) {
cin>>x>>y;
updata(x,1);
updata(y+1,-1);
} else {
cin>>x;
cout<<getsum(x)%2<<endl;
}
}
return 0;
}