import sys
sys.setrecursionlimit(10**9)
def dfs(parent,current,distance):
  global m
  m[current]=distance
  for child in graph[current]:
    if child[0]==parent:
      continue
    dfs(current,child[0],distance+child[1])
n=int(input())
graph=[]
for i in range(n+1):
  graph.append([])
m=[0]*(n+1)
for i in range(n-1):
  a,b,c=map(int,input().split())
  graph[a].append([b,c])
  graph[b].append([a,c])
dfs(1,1,0)
for i in range(1,n+1):
  if m[i]%2==0:
    print(1)
  else:
    print(0) import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def dfs(parent,current,distance):
  global m
  m[current]=distance
  for child in graph[current]:
    if child[0]==parent:
      continue
    dfs(current,child[0],distance+child[1]) dfs global m m[current]=distance m[current] m current distance for child in graph[current]:
    if child[0]==parent:
      continue
    dfs(current,child[0],distance+child[1]) child graph[current] graph current if child[0]==parent:
      continue
     child[0]==parent child[0] child 0 parent continue dfs(current,child[0],distance+child[1]) dfs current child[0] child 0 distance+child[1] distance child[1] child 1 parent parent current current distance distance n=int(input()) n int(input()) int input() input graph=[] graph [] for i in range(n+1):
  graph.append([]) i range(n+1) range n+1 n 1 graph.append([]) graph.append graph append [] m=[0]*(n+1) m [0]*(n+1) [0] 0 n+1 n 1 for i in range(n-1):
  a,b,c=map(int,input().split())
  graph[a].append([b,c])
  graph[b].append([a,c]) i range(n-1) range n-1 n 1 a,b,c=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c graph[a].append([b,c]) [a].append [a] graph a append [b,c] b c graph[b].append([a,c]) [b].append [b] graph b append [a,c] a c dfs(1,1,0) dfs 1 1 0 for i in range(1,n+1):
  if m[i]%2==0:
    print(1)
  else:
    print(0) i range(1,n+1) range 1 n+1 n 1 if m[i]%2==0:
    print(1)
  else:
    print(0) m[i]%2==0 m[i]%2 m[i] m i 2 0 print(1) print 1 print(0) print 0 graph=[] [] graph a,b,c=map(int,input().split()) map(int,input().split()) a def dfs(parent,current,distance):
  global m
  m[current]=distance
  for child in graph[current]:
    if child[0]==parent:
      continue
    dfs(current,child[0],distance+child[1]) def dfs(parent,current,distance):
  global m
  m[current]=distance
  for child in graph[current]:
    if child[0]==parent:
      continue
    dfs(current,child[0],distance+child[1]) dfs n=int(input()) int(input()) n m=[0]*(n+1) [0]*(n+1) m b,c=map(int,input().split()) map(int,input().split()) b c=map(int,input().split()) map(int,input().split()) c
import sys
sys.setrecursionlimit(10**9)
def dfs(parent,current,distance):
  global m
  m[current]=distance
  for child in graph[current]:
    if child[0]==parent:
      continue
    dfs(current,child[0],distance+child[1])
n=int(input())
graph=[]
for i in range(n+1):
  graph.append([])
m=[0]*(n+1)
for i in range(n-1):
  a,b,c=map(int,input().split())
  graph[a].append([b,c])
  graph[b].append([a,c])
dfs(1,1,0)
for i in range(1,n+1):
  if m[i]%2==0:
    print(1)
  else:
    print(0)