from collections import*
n=int(input())
l=[[]for i in range(n)]
ans=[-1 for i in range(n)]
visit=[False for i in range(n)]
ans[0]=0
for i in range(n-1):
    u,v,w=map(int,input().split())
    l[u-1].append((v-1,w))
    l[v-1].append((u-1,w))
      
q=deque()
q.append((0,0,-1))
while q:
    v,d,p=q.popleft()
    if d%2==0:
        ans[v]=0
    else:
        ans[v]=1
    for u,w in l[v]:
        if u==p:
            continue
        q.append((u,d+w,v))
print('\n'.join(map(str, ans))) from collections import* n=int(input()) n int(input()) int input() input []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)] -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 ans=[-1 for i in range(n)] ans [-1 for i in range(n)] False for i in range(n) for i in range(n) i range(n) range n for i in range(n) False visit=[False for i in range(n)] visit [False for i in range(n)] ans[0]=0 ans[0] ans 0 0 for i in range(n-1):
    u,v,w=map(int,input().split())
    l[u-1].append((v-1,w))
    l[v-1].append((u-1,w))
       i 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 l[u-1].append((v-1,w)) [u-1].append [u-1] l u-1 u 1 append (v-1,w) v-1 v 1 w l[v-1].append((u-1,w)) [v-1].append [v-1] l v-1 v 1 append (u-1,w) u-1 u 1 w q=deque() q deque() deque q.append((0,0,-1)) q.append q append (0,0,-1) 0 0 -1 while q:
    v,d,p=q.popleft()
    if d%2==0:
        ans[v]=0
    else:
        ans[v]=1
    for u,w in l[v]:
        if u==p:
            continue
        q.append((u,d+w,v)) q v,d,p=q.popleft() v q.popleft() q.popleft q popleft d p if d%2==0:
        ans[v]=0
    else:
        ans[v]=1
     d%2==0 d%2 d 2 0 ans[v]=0 ans[v] ans v 0 ans[v]=1 ans[v] ans v 1 for u,w in l[v]:
        if u==p:
            continue
        q.append((u,d+w,v)) u w l[v] l v if u==p:
            continue
         u==p u p continue q.append((u,d+w,v)) q.append q append (u,d+w,v) u d+w d w v print('\n'.join(map(str, ans))) print '\n'.join(map(str, ans)) '\n'.join '\n' join map(str, ans) map str ans v,w=map(int,input().split()) map(int,input().split()) v v,d,p=q.popleft() q.popleft() v d,p=q.popleft() q.popleft() d p=q.popleft() q.popleft() p l=[[]for i in range(n)] [[]for i in range(n)] l u,v,w=map(int,input().split()) map(int,input().split()) u q=deque() deque() q ans=[-1 for i in range(n)] [-1 for i in range(n)] ans n=int(input()) int(input()) n visit=[False for i in range(n)] [False for i in range(n)] visit w=map(int,input().split()) map(int,input().split()) w
from collections import*
n=int(input())
l=[[]for i in range(n)]
ans=[-1 for i in range(n)]
visit=[False for i in range(n)]
ans[0]=0
for i in range(n-1):
    u,v,w=map(int,input().split())
    l[u-1].append((v-1,w))
    l[v-1].append((u-1,w))
      
q=deque()
q.append((0,0,-1))
while q:
    v,d,p=q.popleft()
    if d%2==0:
        ans[v]=0
    else:
        ans[v]=1
    for u,w in l[v]:
        if u==p:
            continue
        q.append((u,d+w,v))
print('\n'.join(map(str, ans)))