from collections import deque

N = int(input())
graph = [[] for _ in range(N)]
dist = [-1] * N
for _ in range(N-1):
  u, v, w = map(int, input().split())
  graph[u-1].append((v-1, w))
  graph[v-1].append((u-1, w))
q = deque()

dist[0] = 0
q.append(0)

while len(q) != 0:
  v = q.popleft()
  for next_v, next_w in graph[v]:
    if dist[next_v] != -1:
      continue
    dist[next_v] = dist[v] + next_w
    q.append(next_v)

for d in dist:
  if d%2 == 0:
    print(0)
  else:
    print(1) from collections import deque 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)] dist = [-1] * N dist [-1] * N [-1] -1 N for _ in range(N-1):
  u, v, w = map(int, input().split())
  graph[u-1].append((v-1, w))
  graph[v-1].append((u-1, w)) _ 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 graph[u-1].append((v-1, w)) [u-1].append [u-1] graph u-1 u 1 append (v-1, w) v-1 v 1 w graph[v-1].append((u-1, w)) [v-1].append [v-1] graph v-1 v 1 append (u-1, w) u-1 u 1 w q = deque() q deque() deque dist[0] = 0 dist[0] dist 0 0 q.append(0) q.append q append 0 while len(q) != 0:
  v = q.popleft()
  for next_v, next_w in graph[v]:
    if dist[next_v] != -1:
      continue
    dist[next_v] = dist[v] + next_w
    q.append(next_v) len(q) != 0 len(q) len q 0 v = q.popleft() v q.popleft() q.popleft q popleft for next_v, next_w in graph[v]:
    if dist[next_v] != -1:
      continue
    dist[next_v] = dist[v] + next_w
    q.append(next_v) next_v next_w graph[v] graph v if dist[next_v] != -1:
      continue
     dist[next_v] != -1 dist[next_v] dist next_v -1 continue dist[next_v] = dist[v] + next_w dist[next_v] dist next_v dist[v] + next_w dist[v] dist v next_w q.append(next_v) q.append q append next_v for d in dist:
  if d%2 == 0:
    print(0)
  else:
    print(1) d dist if d%2 == 0:
    print(0)
  else:
    print(1) d%2 == 0 d%2 d 2 0 print(0) print 0 print(1) print 1 dist = [-1] * N [-1] * N dist N = int(input()) int(input()) N v, w = map(int, input().split()) map(int, input().split()) v w = map(int, input().split()) map(int, input().split()) w u, v, w = map(int, input().split()) map(int, input().split()) u q = deque() deque() q v = q.popleft() q.popleft() v graph = [[] for _ in range(N)] [[] for _ in range(N)] graph
from collections import deque

N = int(input())
graph = [[] for _ in range(N)]
dist = [-1] * N
for _ in range(N-1):
  u, v, w = map(int, input().split())
  graph[u-1].append((v-1, w))
  graph[v-1].append((u-1, w))
q = deque()

dist[0] = 0
q.append(0)

while len(q) != 0:
  v = q.popleft()
  for next_v, next_w in graph[v]:
    if dist[next_v] != -1:
      continue
    dist[next_v] = dist[v] + next_w
    q.append(next_v)

for d in dist:
  if d%2 == 0:
    print(0)
  else:
    print(1)