#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

from collections import Counter 
from collections import defaultdict
import itertools
import sys
sys.setrecursionlimit(10**6)

def sol(num,w,node,ans):
    now=node[num]
    
    for each in now:
        ne_n=each[0]
        ne_w=each[1]
        if ans[ne_n]!=-1:
            continue
        if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
        sol(ne_n,ne_w,node,ans)




n=int(input())
node=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=input_list()
    w=w%2
    u-=1
    v-=1
    node[u].append([v,w])
    node[v].append([u,w])

ans=[-1 for _ in range(n)]
ans[0]=0
sol(0,0,node,ans)
for i in ans:
    print(i) input_list = lambda : list(map(int,input().split())) input_list lambda : list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split from collections import Counter from collections import defaultdict import itertools itertools import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 def sol(num,w,node,ans):
    now=node[num]
    
    for each in now:
        ne_n=each[0]
        ne_w=each[1]
        if ans[ne_n]!=-1:
            continue
        if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
        sol(ne_n,ne_w,node,ans) sol now=node[num] now node[num] node num for each in now:
        ne_n=each[0]
        ne_w=each[1]
        if ans[ne_n]!=-1:
            continue
        if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
        sol(ne_n,ne_w,node,ans) each now ne_n=each[0] ne_n each[0] each 0 ne_w=each[1] ne_w each[1] each 1 if ans[ne_n]!=-1:
            continue
         ans[ne_n]!=-1 ans[ne_n] ans ne_n -1 continue if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
         ne_w==0 ne_w 0 ans[ne_n]=ans[num] ans[ne_n] ans ne_n ans[num] ans num ans[ne_n]=1-ans[num] ans[ne_n] ans ne_n 1-ans[num] 1 ans[num] ans num sol(ne_n,ne_w,node,ans) sol ne_n ne_w node ans num num w w node node ans ans n=int(input()) n int(input()) int input() input [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] node=[[] for _ in range(n)] node [[] for _ in range(n)] for _ in range(n-1):
    u,v,w=input_list()
    w=w%2
    u-=1
    v-=1
    node[u].append([v,w])
    node[v].append([u,w]) _ range(n-1) range n-1 n 1 u,v,w=input_list() u input_list() input_list v w w=w%2 w w%2 w 2 u-=1 u 1 v-=1 v 1 node[u].append([v,w]) [u].append [u] node u append [v,w] v w node[v].append([u,w]) [v].append [v] node v append [u,w] u w -1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) -1 ans=[-1 for _ in range(n)] ans [-1 for _ in range(n)] ans[0]=0 ans[0] ans 0 0 sol(0,0,node,ans) sol 0 0 node ans for i in ans:
    print(i) i ans print(i) print i node=[[] for _ in range(n)] [[] for _ in range(n)] node u-=1 1 u n=int(input()) int(input()) n input_list = lambda : list(map(int,input().split())) lambda : list(map(int,input().split())) input_list v-=1 1 v w=input_list() input_list() w v,w=input_list() input_list() v w=w%2 w%2 w ans=[-1 for _ in range(n)] [-1 for _ in range(n)] ans def sol(num,w,node,ans):
    now=node[num]
    
    for each in now:
        ne_n=each[0]
        ne_w=each[1]
        if ans[ne_n]!=-1:
            continue
        if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
        sol(ne_n,ne_w,node,ans) def sol(num,w,node,ans):
    now=node[num]
    
    for each in now:
        ne_n=each[0]
        ne_w=each[1]
        if ans[ne_n]!=-1:
            continue
        if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
        sol(ne_n,ne_w,node,ans) sol u,v,w=input_list() input_list() u
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

from collections import Counter 
from collections import defaultdict
import itertools
import sys
sys.setrecursionlimit(10**6)

def sol(num,w,node,ans):
    now=node[num]
    
    for each in now:
        ne_n=each[0]
        ne_w=each[1]
        if ans[ne_n]!=-1:
            continue
        if ne_w==0:
            ans[ne_n]=ans[num]
        else:
            ans[ne_n]=1-ans[num]
        
        sol(ne_n,ne_w,node,ans)




n=int(input())
node=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=input_list()
    w=w%2
    u-=1
    v-=1
    node[u].append([v,w])
    node[v].append([u,w])

ans=[-1 for _ in range(n)]
ans[0]=0
sol(0,0,node,ans)
for i in ans:
    print(i)