#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int LL; typedef pair P; typedef pair LP; const int INF=1<<30; const LL MAX=1e9+7; void array_show(int *array,int array_n,char middle=' '){ for(int i=0;i &vec_s,int vec_n=-1,char middle=' '){ if(vec_n==-1)vec_n=vec_s.size(); for(int i=0;i &vec_s,int vec_n=-1,char middle=' '){ if(vec_n==-1)vec_n=vec_s.size(); for(int i=0;i> path; vector used; vector vs; bool dfs(int pos,int bef,int y){ if(used[pos])return (vs[pos]^vs[bef])==y; used[pos]=true; if(bef!=-1)vs[pos]=vs[bef]^y; for(auto node:path[pos]){ int to=node.first,y2=node.second; if(to==bef)continue; if(!dfs(to,pos,y2))return false; } return true; } void solve(){ int n,m; int i,j,k; int a,b,c; cin>>n>>m; path.assign(n,vector

()); used.assign(n,0); vs.assign(n,0); for(i=0;i>a>>b>>c; a--,b--; path[a].push_back(make_pair(b,c)); path[b].push_back(make_pair(a,c)); } for(i=0;i