#include #define int int64_t using namespace std; int N; vector> v; vector color(1100, 0); vector adj[1100]; int xx[3]; bool c(int pos, int cc){ if(color[pos]>0){ if(color[pos]==cc)return 0; return 1; } xx[cc]++; color[pos]=cc; bool a; for(auto x:adj[pos]){ a|=c(x, 3-cc); } return a; } signed main(){ ios_base::sync_with_stdio(); cin.tie(0); cin>>N; for(int i=0;i>a>>b>>c; v.push_back({a, b, c}); } for(int i=0;i