// original: https://yukicoder.me/submissions/626069 #pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); #define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} char wbuf[1<<28]; #define WTHI(v) {int _z=v,_n=0;long _d;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;} #define WTLO(v) {int _z=v,_n=8;long _d;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;} #define WT(v) if(v>=100000000){WTHI(v/100000000);WTLO(v);}else{WTHI(v);} #define L 100001 int V[L],X[L]; int root(int a){ if(V[a]<=0) return a; int p=V[a], r=root(p); V[a]=r; X[a]^=X[p]; return r; } int merge(int r,int c,int y){ int rr=root(r), rc=root(c); if(rr==rc) return X[r]^X[c]^y; if(V[rr]<=V[rc]){ V[rr]+=V[rc]-1; V[rc]=r; X[rc]=y^X[c]; }else{ V[rc]+=V[rr]-1; V[rr]=c; X[rr]=y^X[r]; } return 0; } int main(){ char*rp=mmap(0l,1l<<28,1,2,0,0ll); RD(N); RD(M); for(int i=0;i