from collections import deque

def dfs(start):
  stack = deque([[start, 0]])
  while stack:
    p, c = stack.popleft()
    for next, distance in graph[p]:
      if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]])

n = int(input())
graph = [[] for _ in range(n)]
for i in range(n-1):
  a, b, w = map(int, input().split())
  graph[a - 1].append([b - 1, w])
  graph[b - 1].append([a - 1, w])

visited = [-1] * n
visited[0] = 0
dfs(0)
for v in visited:
    print(v) from collections import deque def dfs(start):
  stack = deque([[start, 0]])
  while stack:
    p, c = stack.popleft()
    for next, distance in graph[p]:
      if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]]) dfs stack = deque([[start, 0]]) stack deque([[start, 0]]) deque [[start, 0]] [start, 0] start 0 while stack:
    p, c = stack.popleft()
    for next, distance in graph[p]:
      if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]]) stack p, c = stack.popleft() p stack.popleft() stack.popleft stack popleft c for next, distance in graph[p]:
      if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]]) next distance graph[p] graph p if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]]) visited[next] == -1 visited[next] visited next -1 if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
         distance % 2 == 0 distance % 2 distance 2 0 visited[next] = int(c) visited[next] visited next int(c) int c visited[next] = int(not c) visited[next] visited next int(not c) int not c c stack.append([next, visited[next]]) stack.append stack append [next, visited[next]] next visited[next] visited next start start 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) [] graph = [[] for _ in range(n)] graph [[] for _ in range(n)] for i in range(n-1):
  a, b, w = map(int, input().split())
  graph[a - 1].append([b - 1, w])
  graph[b - 1].append([a - 1, w]) i range(n-1) range n-1 n 1 a, b, w = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b w graph[a - 1].append([b - 1, w]) [a - 1].append [a - 1] graph a - 1 a 1 append [b - 1, w] b - 1 b 1 w graph[b - 1].append([a - 1, w]) [b - 1].append [b - 1] graph b - 1 b 1 append [a - 1, w] a - 1 a 1 w visited = [-1] * n visited [-1] * n [-1] -1 n visited[0] = 0 visited[0] visited 0 0 dfs(0) dfs 0 for v in visited:
    print(v) v visited print(v) print v b, w = map(int, input().split()) map(int, input().split()) b graph = [[] for _ in range(n)] [[] for _ in range(n)] graph n = int(input()) int(input()) n visited = [-1] * n [-1] * n visited w = map(int, input().split()) map(int, input().split()) w a, b, w = map(int, input().split()) map(int, input().split()) a def dfs(start):
  stack = deque([[start, 0]])
  while stack:
    p, c = stack.popleft()
    for next, distance in graph[p]:
      if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]]) def dfs(start):
  stack = deque([[start, 0]])
  while stack:
    p, c = stack.popleft()
    for next, distance in graph[p]:
      if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]]) dfs
from collections import deque

def dfs(start):
  stack = deque([[start, 0]])
  while stack:
    p, c = stack.popleft()
    for next, distance in graph[p]:
      if visited[next] == -1:
        if distance % 2 == 0:
          visited[next] = int(c)
        else:
          visited[next] = int(not c)
        stack.append([next, visited[next]])

n = int(input())
graph = [[] for _ in range(n)]
for i in range(n-1):
  a, b, w = map(int, input().split())
  graph[a - 1].append([b - 1, w])
  graph[b - 1].append([a - 1, w])

visited = [-1] * n
visited[0] = 0
dfs(0)
for v in visited:
    print(v)