#include #include #include #include using namespace std; //ifstream F("p.in"); //ofstream G("p.out"); #define F cin #define G cout const int N = 100010; const int M = 320; int n,m,len; int beg[N],end[N],ord[N],el[M]; int rev[M],val[N],sum[M]; void init() { len = int(sqrt(double(n))); int last = 1; for (int i=1,j=1,co=1;i<=n;++i,++j) { beg[i] = last; ord[i] = co; el[co]++; if ( j == len ) { for (int k=beg[i];k<=i;++k) end[k] = i; last = i+1; j = 0; co++; } } } void update(int l,int r) { int i; for (i=l;i<=end[l];++i) { sum[ord[i]] = sum[ord[i]] - val[i]; val[i] = 1-val[i]; sum[ord[i]] = sum[ord[i]] + val[i]; } for (i=i+1;i<=r;i+=len) rev[ord[i]] = rev[ord[i]] ^ 1; i -= len; for (i=i+1;i<=r;++i) val[i] = 1-val[i]; } int calc(int pos) { int v = val[pos]; int tv = rev[ord[pos]] ? v : 1-v; return tv; } int segm(int pos) { if ( rev[pos] ) return el[pos]-sum[pos]; else return sum[pos]; } void query(int pos) { int what = len * calc(pos); int left = pos; int i=pos; while ( i>=beg[pos] && calc(i) == calc(pos) ) --i; if ( i == beg[pos]-1 ) { ++i; while ( what == segm(ord[i]) && i > 0 ) i -= len; if ( i <= 0 ) i = 0; else { while ( calc(i) == calc(pos) ) --i; } } left = i+1; int right = pos; i = pos; while ( i<=end[pos] && calc(i) == calc(pos) ) ++i; if ( i == end[pos]+1 ) { i = i-1; while ( what == segm(ord[i]) && i <= n ) i += len; if ( i > n ) i = n; else { while ( calc(i) == calc(pos) ) ++i; } right = i-1; } else right = i; G<<1-calc(pos)<<' '<>n>>m; init(); for (int i=1,type,a,b;i<=m;++i) { F>>type; if ( type == 1 ) { F>>a>>b; update(a,b); } else { F>>a; query(a); } //for (int j=1;j<=n;++j) G<