#include<bits/stdc++.h>
using namespace std;
namespace Tree{
const int maxn=100005;
int val[maxn];
int n,m;
int ans=0;
struct tree{
int l,r;
int lson,rson;
int tag;
int num;
}a[maxn*4];
void pushup(int x){
if(a[a[x].lson].num==1&&a[a[x].rson].num==1)
a[x].num=1;
else if(a[a[x].lson].num==0&&a[a[x].rson].num==0)
a[x].num=0;
else a[x].num=-1;
}
int cnt=0;
int Root;
void Build(int &x,int l,int r){
if(x==0){
x=++cnt;
a[x].l=l;
a[x].r=r;
a[x].tag=-1;
}
if(l==r){
a[x].num=0;
return ;
}
int mid=(l+r)/2;
Build(a[x].lson,l,mid);
Build(a[x].rson,mid+1,r);
pushup(x);
}
void pushdown(int x){
if(a[x].tag==-1)
return ;
a[a[x].lson].num=a[x].tag;
a[a[x].rson].num=a[x].tag;
a[a[x].lson].tag=a[x].tag;
a[a[x].rson].tag=a[x].tag;
a[x].tag=-1;
}
void change(int x,int l,int r){
if(a[x].r<l||a[x].l>r)
return ;
if(l<=a[x].l&&a[x].r<=r){
int op=(a[x].num==1)?0:1;
a[x].num=op;
a[x].tag=op;
return ;
}
pushdown(x);
change(a[x].lson,l,r);
change(a[x].rson,l,r);
pushup(x);
}
void ask(int x,int f){
if(f<a[x].l||f>a[x].r)
return ;
if(a[x].l==a[x].r){
ans=a[x].num;
return ;
}
pushdown(x);
ask(a[x].lson,f);
ask(a[x].rson,f);
pushup(x);
}
int main(){
cin>>n>>m;
Build(Root,1,n);
for(int i=1;i<=m;i++){
int op;
int x,y;
cin>>op;
if(op==1){
cin>>x>>y;
change(Root,x,y);
}
if(op==2){
cin>>x;
ans=0;
ask(Root,x);
cout<<ans<<endl;
}
}
return 0;
}
}
int main(){return Tree::main();}