n=int(input())

#隣接リスト表現
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v-1,w])
  es[v-1].append([u-1,w])


# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)

#頂点vから初めて白なら１、黒なら−１、未探索なら０
colors=[0 for i in range(n)]
def search(v,color):
  colors[v]=color
  #vから行ける辺について考える
  for to in es[v]:
    if colors[to[0]]==0 and to[1]%2==0:
      search(to[0],color)
    elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
  return colors

search(0,1)
for i in colors:
  if i==-1:
    print(0)
  else:
    print(1)
    
  
  
 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) [] es=[[] for i in range(n)] es [[] for i in range(n)] for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v-1,w])
  es[v-1].append([u-1,w])


# 再帰の深さが1000を超えそうなときはこれをやっておく i range(n-1) range n-1 n 1 u,v,w=list(map(int,input().split())) u list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split v w es[u-1].append([v-1,w]) [u-1].append [u-1] es u-1 u 1 append [v-1,w] v-1 v 1 w es[v-1].append([u-1,w]) [v-1].append [v-1] es v-1 v 1 append [u-1,w] u-1 u 1 w import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 colors=[0 for i in range(n)] colors [0 for i in range(n)] def search(v,color):
  colors[v]=color
  #vから行ける辺について考える
  for to in es[v]:
    if colors[to[0]]==0 and to[1]%2==0:
      search(to[0],color)
    elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
  return colors search colors[v]=color colors[v] colors v color for to in es[v]:
    if colors[to[0]]==0 and to[1]%2==0:
      search(to[0],color)
    elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
   to es[v] es v if colors[to[0]]==0 and to[1]%2==0:
      search(to[0],color)
    elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
   colors[to[0]]==0 and to[1]%2==0 colors[to[0]]==0 colors[to[0]] colors to[0] to 0 0 to[1]%2==0 to[1]%2 to[1] to 1 2 0 search(to[0],color) search to[0] to 0 color elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
   colors[to[0]]==0 and to[1]%2==1 colors[to[0]]==0 colors[to[0]] colors to[0] to 0 0 to[1]%2==1 to[1]%2 to[1] to 1 2 1 search(to[0],-color) search to[0] to 0 -color color return colors colors v v color color search(0,1) search 0 1 for i in colors:
  if i==-1:
    print(0)
  else:
    print(1)
    
  
   i colors if i==-1:
    print(0)
  else:
    print(1)
    
  
   i==-1 i -1 print(0) print 0 print(1) print 1 w=list(map(int,input().split())) list(map(int,input().split())) w es=[[] for i in range(n)] [[] for i in range(n)] es v,w=list(map(int,input().split())) list(map(int,input().split())) v def search(v,color):
  colors[v]=color
  #vから行ける辺について考える
  for to in es[v]:
    if colors[to[0]]==0 and to[1]%2==0:
      search(to[0],color)
    elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
  return colors def search(v,color):
  colors[v]=color
  #vから行ける辺について考える
  for to in es[v]:
    if colors[to[0]]==0 and to[1]%2==0:
      search(to[0],color)
    elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
  return colors search colors=[0 for i in range(n)] [0 for i in range(n)] colors n=int(input()) int(input()) n u,v,w=list(map(int,input().split())) list(map(int,input().split())) u
n=int(input())

#隣接リスト表現
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v-1,w])
  es[v-1].append([u-1,w])


# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)

#頂点vから初めて白なら１、黒なら−１、未探索なら０
colors=[0 for i in range(n)]
def search(v,color):
  colors[v]=color
  #vから行ける辺について考える
  for to in es[v]:
    if colors[to[0]]==0 and to[1]%2==0:
      search(to[0],color)
    elif colors[to[0]]==0 and to[1]%2==1:
      search(to[0],-color)
  return colors

search(0,1)
for i in colors:
  if i==-1:
    print(0)
  else:
    print(1)
    
  
  

