from collections import deque

n=int(input())
ch=0
g=[[] for _ in range(n)]
k=[[] for _ in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  if w%2==0:
    g[u-1].append(v-1)
    g[v-1].append(u-1)
  else:
    k[u-1].append(v-1)
    k[v-1].append(u-1)
    ch1=u-1
    ch2=v-1
    ch=1

## 0:White 1:Black
ans=[-1 for _ in range(n)]

if ch>0:
  ans[ch1]=0
  d=[ch1]
  qu=deque(d)
  while qu:
    p=qu.popleft()
    
    for gr in g[p]:
      if ans[gr]==-1:
        if ans[p]==0:
          ans[gr]=0
          qu.append(gr)
        else:
          ans[gr]=1
          qu.append(gr)
      
    for kr in k[p]:
      if ans[kr]==-1:
        if ans[p]==0:
          ans[kr]=1
          qu.append(kr)
        else:
          ans[kr]=0
          qu.append(kr)   
    
          
  for j in range(n):
    print(ans[j])
    
else:
  for j in range(n):
    print(0)
      
  
 from collections import deque n=int(input()) n int(input()) int input() input ch=0 ch 0 [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] g=[[] for _ in range(n)] g [[] for _ in range(n)] [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] k=[[] for _ in range(n)] k [[] for _ in range(n)] for i in range(n-1):
  u,v,w=map(int,input().split())
  if w%2==0:
    g[u-1].append(v-1)
    g[v-1].append(u-1)
  else:
    k[u-1].append(v-1)
    k[v-1].append(u-1)
    ch1=u-1
    ch2=v-1
    ch=1

## 0:White 1:Black 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 if w%2==0:
    g[u-1].append(v-1)
    g[v-1].append(u-1)
  else:
    k[u-1].append(v-1)
    k[v-1].append(u-1)
    ch1=u-1
    ch2=v-1
    ch=1

## 0:White 1:Black w%2==0 w%2 w 2 0 g[u-1].append(v-1) [u-1].append [u-1] g u-1 u 1 append v-1 v 1 g[v-1].append(u-1) [v-1].append [v-1] g v-1 v 1 append u-1 u 1 k[u-1].append(v-1) [u-1].append [u-1] k u-1 u 1 append v-1 v 1 k[v-1].append(u-1) [v-1].append [v-1] k v-1 v 1 append u-1 u 1 ch1=u-1 ch1 u-1 u 1 ch2=v-1 ch2 v-1 v 1 ch=1 ch 1 -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)] if ch>0:
  ans[ch1]=0
  d=[ch1]
  qu=deque(d)
  while qu:
    p=qu.popleft()
    
    for gr in g[p]:
      if ans[gr]==-1:
        if ans[p]==0:
          ans[gr]=0
          qu.append(gr)
        else:
          ans[gr]=1
          qu.append(gr)
      
    for kr in k[p]:
      if ans[kr]==-1:
        if ans[p]==0:
          ans[kr]=1
          qu.append(kr)
        else:
          ans[kr]=0
          qu.append(kr)   
    
          
  for j in range(n):
    print(ans[j])
    
else:
  for j in range(n):
    print(0)
      
   ch>0 ch 0 ans[ch1]=0 ans[ch1] ans ch1 0 d=[ch1] d [ch1] ch1 qu=deque(d) qu deque(d) deque d while qu:
    p=qu.popleft()
    
    for gr in g[p]:
      if ans[gr]==-1:
        if ans[p]==0:
          ans[gr]=0
          qu.append(gr)
        else:
          ans[gr]=1
          qu.append(gr)
      
    for kr in k[p]:
      if ans[kr]==-1:
        if ans[p]==0:
          ans[kr]=1
          qu.append(kr)
        else:
          ans[kr]=0
          qu.append(kr)   
    
          
   qu p=qu.popleft() p qu.popleft() qu.popleft qu popleft for gr in g[p]:
      if ans[gr]==-1:
        if ans[p]==0:
          ans[gr]=0
          qu.append(gr)
        else:
          ans[gr]=1
          qu.append(gr)
      
     gr g[p] g p if ans[gr]==-1:
        if ans[p]==0:
          ans[gr]=0
          qu.append(gr)
        else:
          ans[gr]=1
          qu.append(gr)
      
     ans[gr]==-1 ans[gr] ans gr -1 if ans[p]==0:
          ans[gr]=0
          qu.append(gr)
        else:
          ans[gr]=1
          qu.append(gr)
      
     ans[p]==0 ans[p] ans p 0 ans[gr]=0 ans[gr] ans gr 0 qu.append(gr) qu.append qu append gr ans[gr]=1 ans[gr] ans gr 1 qu.append(gr) qu.append qu append gr for kr in k[p]:
      if ans[kr]==-1:
        if ans[p]==0:
          ans[kr]=1
          qu.append(kr)
        else:
          ans[kr]=0
          qu.append(kr)   
    
          
   kr k[p] k p if ans[kr]==-1:
        if ans[p]==0:
          ans[kr]=1
          qu.append(kr)
        else:
          ans[kr]=0
          qu.append(kr)   
    
          
   ans[kr]==-1 ans[kr] ans kr -1 if ans[p]==0:
          ans[kr]=1
          qu.append(kr)
        else:
          ans[kr]=0
          qu.append(kr)   
    
          
   ans[p]==0 ans[p] ans p 0 ans[kr]=1 ans[kr] ans kr 1 qu.append(kr) qu.append qu append kr ans[kr]=0 ans[kr] ans kr 0 qu.append(kr) qu.append qu append kr for j in range(n):
    print(ans[j])
     j range(n) range n print(ans[j]) print ans[j] ans j for j in range(n):
    print(0)
      
   j range(n) range n print(0) print 0 u,v,w=map(int,input().split()) map(int,input().split()) u n=int(input()) int(input()) n v,w=map(int,input().split()) map(int,input().split()) v qu=deque(d) deque(d) qu ch=0 0 ch g=[[] for _ in range(n)] [[] for _ in range(n)] g ch=1 1 ch d=[ch1] [ch1] d ans=[-1 for _ in range(n)] [-1 for _ in range(n)] ans ch1=u-1 u-1 ch1 k=[[] for _ in range(n)] [[] for _ in range(n)] k p=qu.popleft() qu.popleft() p w=map(int,input().split()) map(int,input().split()) w ch2=v-1 v-1 ch2
from collections import deque

n=int(input())
ch=0
g=[[] for _ in range(n)]
k=[[] for _ in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  if w%2==0:
    g[u-1].append(v-1)
    g[v-1].append(u-1)
  else:
    k[u-1].append(v-1)
    k[v-1].append(u-1)
    ch1=u-1
    ch2=v-1
    ch=1

## 0:White 1:Black
ans=[-1 for _ in range(n)]

if ch>0:
  ans[ch1]=0
  d=[ch1]
  qu=deque(d)
  while qu:
    p=qu.popleft()
    
    for gr in g[p]:
      if ans[gr]==-1:
        if ans[p]==0:
          ans[gr]=0
          qu.append(gr)
        else:
          ans[gr]=1
          qu.append(gr)
      
    for kr in k[p]:
      if ans[kr]==-1:
        if ans[p]==0:
          ans[kr]=1
          qu.append(kr)
        else:
          ans[kr]=0
          qu.append(kr)   
    
          
  for j in range(n):
    print(ans[j])
    
else:
  for j in range(n):
    print(0)
      
  

