N = int(input())
G = [[] for n in range(N+1)]
q = [(1,0)]
ans = N*[-1]

for n in range(N-1):
  u,v,w = map(int,input().split())
  G[u]+=[(v,w)]
  G[v]+=[(u,w)]

while q:
  x,y = q.pop()
  ans[x-1] = y%2 
  for g,d in G[x]:
    q+=[(g,y+d)]*(ans[g-1]<0)

print(*ans,sep="\n") N = int(input()) N int(input()) int input() input [] for n in range(N+1) for n in range(N+1) n range(N+1) range N+1 N 1 for n in range(N+1) [] G = [[] for n in range(N+1)] G [[] for n in range(N+1)] q = [(1,0)] q [(1,0)] (1,0) 1 0 ans = N*[-1] ans N*[-1] N [-1] -1 for n in range(N-1):
  u,v,w = map(int,input().split())
  G[u]+=[(v,w)]
  G[v]+=[(u,w)] n range(N-1) range N-1 N 1 u,v,w = map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v w G[u]+=[(v,w)] G[u] G u [(v,w)] (v,w) v w G[v]+=[(u,w)] G[v] G v [(u,w)] (u,w) u w while q:
  x,y = q.pop()
  ans[x-1] = y%2 
  for g,d in G[x]:
    q+=[(g,y+d)]*(ans[g-1]<0) q x,y = q.pop() x q.pop() q.pop q pop y ans[x-1] = y%2 ans[x-1] ans x-1 x 1 y%2 y 2 for g,d in G[x]:
    q+=[(g,y+d)]*(ans[g-1]<0) g d G[x] G x q+=[(g,y+d)]*(ans[g-1]<0) q [(g,y+d)]*(ans[g-1]<0) [(g,y+d)] (g,y+d) g y+d y d ans[g-1]<0 ans[g-1] ans g-1 g 1 0 print(*ans,sep="\n") print *ans ans sep="\n" sep "\n" ans = N*[-1] N*[-1] ans N = int(input()) int(input()) N w = map(int,input().split()) map(int,input().split()) w v,w = map(int,input().split()) map(int,input().split()) v G = [[] for n in range(N+1)] [[] for n in range(N+1)] G x,y = q.pop() q.pop() x q+=[(g,y+d)]*(ans[g-1]<0) [(g,y+d)]*(ans[g-1]<0) q y = q.pop() q.pop() y u,v,w = map(int,input().split()) map(int,input().split()) u q = [(1,0)] [(1,0)] q
N = int(input())
G = [[] for n in range(N+1)]
q = [(1,0)]
ans = N*[-1]

for n in range(N-1):
  u,v,w = map(int,input().split())
  G[u]+=[(v,w)]
  G[v]+=[(u,w)]

while q:
  x,y = q.pop()
  ans[x-1] = y%2 
  for g,d in G[x]:
    q+=[(g,y+d)]*(ans[g-1]<0)

print(*ans,sep="\n")