import sys
sys.setrecursionlimit(100000000)

def dfs(node,distance):
  for next_node,edge_distangce in G[node]:
    if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce)

n=int(input())
G=[[] for _ in range(n)]

for i in range(n-1):
  u,v,w = map(int,input().split())
  G[u-1].append([v-1,w])
  G[v-1].append([u-1,w])

ans = [-1]*n
dfs(0,0)
print(*ans,sep='\n') import sys sys sys.setrecursionlimit(100000000) sys.setrecursionlimit sys setrecursionlimit 100000000 def dfs(node,distance):
  for next_node,edge_distangce in G[node]:
    if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce) dfs for next_node,edge_distangce in G[node]:
    if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce) next_node edge_distangce G[node] G node if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce) ans[next_node]==-1 ans[next_node] ans next_node -1 ans[next_node]=(distance+edge_distangce)%2 ans[next_node] ans next_node (distance+edge_distangce)%2 distance+edge_distangce distance edge_distangce 2 dfs(next_node,distance+edge_distangce) dfs next_node distance+edge_distangce distance edge_distangce node node distance distance 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) [] G=[[] for _ in range(n)] G [[] for _ in range(n)] for i in range(n-1):
  u,v,w = map(int,input().split())
  G[u-1].append([v-1,w])
  G[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 G[u-1].append([v-1,w]) [u-1].append [u-1] G u-1 u 1 append [v-1,w] v-1 v 1 w G[v-1].append([u-1,w]) [v-1].append [v-1] G v-1 v 1 append [u-1,w] u-1 u 1 w ans = [-1]*n ans [-1]*n [-1] -1 n dfs(0,0) dfs 0 0 print(*ans,sep='\n') print *ans ans sep='\n' sep '\n' def dfs(node,distance):
  for next_node,edge_distangce in G[node]:
    if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce) def dfs(node,distance):
  for next_node,edge_distangce in G[node]:
    if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce) dfs v,w = map(int,input().split()) map(int,input().split()) v n=int(input()) int(input()) n ans = [-1]*n [-1]*n ans u,v,w = map(int,input().split()) map(int,input().split()) u w = map(int,input().split()) map(int,input().split()) w G=[[] for _ in range(n)] [[] for _ in range(n)] G
import sys
sys.setrecursionlimit(100000000)

def dfs(node,distance):
  for next_node,edge_distangce in G[node]:
    if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce)

n=int(input())
G=[[] for _ in range(n)]

for i in range(n-1):
  u,v,w = map(int,input().split())
  G[u-1].append([v-1,w])
  G[v-1].append([u-1,w])

ans = [-1]*n
dfs(0,0)
print(*ans,sep='\n')
