# -*- coding: utf-8 -*-
#D - Even Relation
import sys 
from heapq import heappush, heappop
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())

edges = [[] for _ in range(N+1)]
INF = 10**31
dist = [INF]*(N+1) #最短距離用
prev=[None]*(N+1) #最短経路用
for _ in range(N-1):
  x,y,t = map(int, readline().split())
  edges[x].append((y,t))
  edges[y].append((x,t))
  
q = [(0,1)]
dist[1] = 0 #最短経路用
while q:
  cost, v = heappop(q)
  if dist[v] < cost:
    continue
  for vert,_cost in edges[v]:
    newcost = cost+_cost
    if newcost < dist[vert]:
      prev[vert] = v
      dist[vert] = newcost #最短経路用
      heappush(q,(newcost,vert))

for i in range(1,N+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1) import sys sys from heapq import heappush, heappop read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines N = int(readline()) N int(readline()) int readline() readline [] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] edges = [[] for _ in range(N+1)] edges [[] for _ in range(N+1)] INF = 10**31 INF 10**31 10 31 dist = [INF]*(N+1) dist [INF]*(N+1) [INF] INF N+1 N 1 prev=[None]*(N+1) prev [None]*(N+1) [None] None N+1 N 1 for _ in range(N-1):
  x,y,t = map(int, readline().split())
  edges[x].append((y,t))
  edges[y].append((x,t))
   _ range(N-1) range N-1 N 1 x,y,t = map(int, readline().split()) x map(int, readline().split()) map int readline().split() ().split () readline split y t edges[x].append((y,t)) [x].append [x] edges x append (y,t) y t edges[y].append((x,t)) [y].append [y] edges y append (x,t) x t q = [(0,1)] q [(0,1)] (0,1) 0 1 dist[1] = 0 dist[1] dist 1 0 while q:
  cost, v = heappop(q)
  if dist[v] < cost:
    continue
  for vert,_cost in edges[v]:
    newcost = cost+_cost
    if newcost < dist[vert]:
      prev[vert] = v
      dist[vert] = newcost #最短経路用
      heappush(q,(newcost,vert)) q cost, v = heappop(q) cost heappop(q) heappop q v if dist[v] < cost:
    continue
   dist[v] < cost dist[v] dist v cost continue for vert,_cost in edges[v]:
    newcost = cost+_cost
    if newcost < dist[vert]:
      prev[vert] = v
      dist[vert] = newcost #最短経路用
      heappush(q,(newcost,vert)) vert _cost edges[v] edges v newcost = cost+_cost newcost cost+_cost cost _cost if newcost < dist[vert]:
      prev[vert] = v
      dist[vert] = newcost #最短経路用
      heappush(q,(newcost,vert)) newcost < dist[vert] newcost dist[vert] dist vert prev[vert] = v prev[vert] prev vert v dist[vert] = newcost dist[vert] dist vert newcost heappush(q,(newcost,vert)) heappush q (newcost,vert) newcost vert for i in range(1,N+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1) i range(1,N+1) range 1 N+1 N 1 if dist[i] % 2 == 0:
        print(0)
    else:
        print(1) dist[i] % 2 == 0 dist[i] % 2 dist[i] dist i 2 0 print(0) print 0 print(1) print 1 read = sys.stdin.buffer.read sys.stdin.buffer.read read q = [(0,1)] [(0,1)] q prev=[None]*(N+1) [None]*(N+1) prev readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline t = map(int, readline().split()) map(int, readline().split()) t y,t = map(int, readline().split()) map(int, readline().split()) y x,y,t = map(int, readline().split()) map(int, readline().split()) x N = int(readline()) int(readline()) N edges = [[] for _ in range(N+1)] [[] for _ in range(N+1)] edges v = heappop(q) heappop(q) v readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines INF = 10**31 10**31 INF cost, v = heappop(q) heappop(q) cost dist = [INF]*(N+1) [INF]*(N+1) dist newcost = cost+_cost cost+_cost newcost
# -*- coding: utf-8 -*-
#D - Even Relation
import sys 
from heapq import heappush, heappop
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())

edges = [[] for _ in range(N+1)]
INF = 10**31
dist = [INF]*(N+1) #最短距離用
prev=[None]*(N+1) #最短経路用
for _ in range(N-1):
  x,y,t = map(int, readline().split())
  edges[x].append((y,t))
  edges[y].append((x,t))
  
q = [(0,1)]
dist[1] = 0 #最短経路用
while q:
  cost, v = heappop(q)
  if dist[v] < cost:
    continue
  for vert,_cost in edges[v]:
    newcost = cost+_cost
    if newcost < dist[vert]:
      prev[vert] = v
      dist[vert] = newcost #最短経路用
      heappush(q,(newcost,vert))

for i in range(1,N+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)