from collections import deque
N=int(input())
visited=[-1]*N
l=[[] for i in range(N)]
for i in range(N-1):
   a,b,c=map(int,input().split())
   a-=1;b-=1
   l[a].append((b,c%2))
   l[b].append((a,c%2))
def ans(node,dis):
   visited[node]=0
   que=deque(l[node])
   while que:
      node,dis=que.popleft()
      visited[node]=dis
      for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2))
ans(0,0)
for i in visited:
   print(i) from collections import deque N=int(input()) N int(input()) int input() input visited=[-1]*N visited [-1]*N [-1] -1 N [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] l=[[] for i in range(N)] l [[] for i in range(N)] for i in range(N-1):
   a,b,c=map(int,input().split())
   a-=1;b-=1
   l[a].append((b,c%2))
   l[b].append((a,c%2)) i range(N-1) range N-1 N 1 a,b,c=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c a-=1 a 1 b-=1 b 1 l[a].append((b,c%2)) [a].append [a] l a append (b,c%2) b c%2 c 2 l[b].append((a,c%2)) [b].append [b] l b append (a,c%2) a c%2 c 2 def ans(node,dis):
   visited[node]=0
   que=deque(l[node])
   while que:
      node,dis=que.popleft()
      visited[node]=dis
      for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2)) ans visited[node]=0 visited[node] visited node 0 que=deque(l[node]) que deque(l[node]) deque l[node] l node while que:
      node,dis=que.popleft()
      visited[node]=dis
      for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2)) que node,dis=que.popleft() node que.popleft() que.popleft que popleft dis visited[node]=dis visited[node] visited node dis for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2)) i j l[node] l node if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2)) visited[i]==-1 visited[i] visited i -1 visited[i]=(dis+j)%2 visited[i] visited i (dis+j)%2 dis+j dis j 2 que.append((i,(dis+j)%2)) que.append que append (i,(dis+j)%2) i (dis+j)%2 dis+j dis j 2 node node dis dis ans(0,0) ans 0 0 for i in visited:
   print(i) i visited print(i) print i b-=1 1 b a-=1 1 a l=[[] for i in range(N)] [[] for i in range(N)] l visited=[-1]*N [-1]*N visited N=int(input()) int(input()) N b,c=map(int,input().split()) map(int,input().split()) b c=map(int,input().split()) map(int,input().split()) c a,b,c=map(int,input().split()) map(int,input().split()) a def ans(node,dis):
   visited[node]=0
   que=deque(l[node])
   while que:
      node,dis=que.popleft()
      visited[node]=dis
      for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2)) def ans(node,dis):
   visited[node]=0
   que=deque(l[node])
   while que:
      node,dis=que.popleft()
      visited[node]=dis
      for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2)) ans
from collections import deque
N=int(input())
visited=[-1]*N
l=[[] for i in range(N)]
for i in range(N-1):
   a,b,c=map(int,input().split())
   a-=1;b-=1
   l[a].append((b,c%2))
   l[b].append((a,c%2))
def ans(node,dis):
   visited[node]=0
   que=deque(l[node])
   while que:
      node,dis=que.popleft()
      visited[node]=dis
      for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2))
ans(0,0)
for i in visited:
   print(i)