import sys
sys.setrecursionlimit(100001)

def dfs(node,w):
  weight = w
  for l in tree[node]:
    if color[l[0]] > -1:
      continue
    color[l[0]] = int (not ((l[1]%2==0) ^ color[node]))
    
    dfs(l[0],l[1])
    


N = int(input())
tree = {}
color = [-1]*(N+1)

for i in range(1,N+1):
  tree[i] = []
for i in range(N-1):
  u,v,w = map(int,input().split())
  tree[u].append([v,w])
  tree[v].append([u,w])
  
color[1] = 0
dfs(1,0)
print('\n'.join(map(str,color[1:]))) import sys sys sys.setrecursionlimit(100001) sys.setrecursionlimit sys setrecursionlimit 100001 def dfs(node,w):
  weight = w
  for l in tree[node]:
    if color[l[0]] > -1:
      continue
    color[l[0]] = int (not ((l[1]%2==0) ^ color[node]))
    
    dfs(l[0],l[1])
     dfs weight = w weight w for l in tree[node]:
    if color[l[0]] > -1:
      continue
    color[l[0]] = int (not ((l[1]%2==0) ^ color[node]))
    
    dfs(l[0],l[1])
     l tree[node] tree node if color[l[0]] > -1:
      continue
     color[l[0]] > -1 color[l[0]] color l[0] l 0 -1 continue color[l[0]] = int (not ((l[1]%2==0) ^ color[node])) color[l[0]] color l[0] l 0 int (not ((l[1]%2==0) ^ color[node])) int not ((l[1]%2==0) ^ color[node]) (l[1]%2==0) ^ color[node] l[1]%2==0 l[1]%2 l[1] l 1 2 0 color[node] color node dfs(l[0],l[1]) dfs l[0] l 0 l[1] l 1 node node w w N = int(input()) N int(input()) int input() input tree = {} tree {} color = [-1]*(N+1) color [-1]*(N+1) [-1] -1 N+1 N 1 for i in range(1,N+1):
  tree[i] = [] i range(1,N+1) range 1 N+1 N 1 tree[i] = [] tree[i] tree i [] for i in range(N-1):
  u,v,w = map(int,input().split())
  tree[u].append([v,w])
  tree[v].append([u,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 tree[u].append([v,w]) [u].append [u] tree u append [v,w] v w tree[v].append([u,w]) [v].append [v] tree v append [u,w] u w color[1] = 0 color[1] color 1 0 dfs(1,0) dfs 1 0 print('\n'.join(map(str,color[1:]))) print '\n'.join(map(str,color[1:])) '\n'.join '\n' join map(str,color[1:]) map str color[1:] color 1: 1 N = int(input()) int(input()) N v,w = map(int,input().split()) map(int,input().split()) v tree = {} {} tree u,v,w = map(int,input().split()) map(int,input().split()) u def dfs(node,w):
  weight = w
  for l in tree[node]:
    if color[l[0]] > -1:
      continue
    color[l[0]] = int (not ((l[1]%2==0) ^ color[node]))
    
    dfs(l[0],l[1])
     def dfs(node,w):
  weight = w
  for l in tree[node]:
    if color[l[0]] > -1:
      continue
    color[l[0]] = int (not ((l[1]%2==0) ^ color[node]))
    
    dfs(l[0],l[1])
     dfs w = map(int,input().split()) map(int,input().split()) w color = [-1]*(N+1) [-1]*(N+1) color
import sys
sys.setrecursionlimit(100001)

def dfs(node,w):
  weight = w
  for l in tree[node]:
    if color[l[0]] > -1:
      continue
    color[l[0]] = int (not ((l[1]%2==0) ^ color[node]))
    
    dfs(l[0],l[1])
    


N = int(input())
tree = {}
color = [-1]*(N+1)

for i in range(1,N+1):
  tree[i] = []
for i in range(N-1):
  u,v,w = map(int,input().split())
  tree[u].append([v,w])
  tree[v].append([u,w])
  
color[1] = 0
dfs(1,0)
print('\n'.join(map(str,color[1:])))