#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair P; int n, m; vector

g[100010]; int y[100010]; int a[100010], b[100010]; bool used[100010]; int ans[100010]; bool dame; void dfs(int x){ used[x]=1; for(auto p:g[x]){ int z=p.first; int i=p.second; if(!used[z]){ ans[z]=(y[i]^ans[x]); dfs(z); }else if(ans[z]!=(y[i]^ans[x])){ dame=1; } } } int main() { cin>>n>>m; for(int i=0; i>a[i]>>b[i]>>y[i]; a[i]--; b[i]--; g[a[i]].push_back({b[i], i}); g[b[i]].push_back({a[i], i}); } for(int i=0; i