# 「bzoj 4025: 二分图」

#include<cstdio>
#include<vector>
#define re register
char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
std::vector<int> u[320005],v[320005],f[320005],st[320005];
int n,m,T,now,tp;
int ans[100005],fa[100005],h[100005],dis[100005];
void change(int l,int r,int x,int y,int i,int a,int b) {
if(x<=l&&y>=r) {u[i].push_back(a),v[i].push_back(b);return;}
int mid=l+r>>1;
if(x<=mid) change(l,mid,x,y,i<<1,a,b);
if(y>=mid+1) change(mid+1,r,x,y,i<<1|1,a,b);
}
inline int find(int x,int opt) {
if(!opt) now=0;
while(fa[x]!=x) now^=dis[x],x=fa[x];
return x;
}
inline int merge(int x,int y) {
tp=0;
if(h[x]<h[y]) {dis[x]=(now^1);fa[x]=y;return x;}
if(h[y]<h[x]) {dis[y]=(now^1);fa[y]=x;return y;}
h[x]++;fa[y]=x;tp=1;dis[y]=(now^1);return y;
}
inline void clear(int i) {
for(re int j=st[i].size()-1;~j;--j) {
int x=st[i][j];
h[fa[x]]-=f[i][j];fa[x]=x;
}
}
void solve(int l,int r,int i) {
for(re int j=0;j<u[i].size();j++) {
int xx=find(u[i][j],0),yy=find(v[i][j],1);
if(xx!=yy) st[i].push_back(merge(xx,yy)),f[i].push_back(tp);
else if(!now) {
for(re int k=l;k<=r;k++) ans[k]=1;
clear(i);return;
}
}
if(l==r) {clear(i);return;}
int mid=l+r>>1;
solve(mid+1,r,i<<1|1);solve(l,mid,i<<1);
clear(i);
}
int main() {