from collections import deque
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
  u, v, w = map(int, input().split())
  g[u-1].append((v-1,w))
  g[v-1].append((u-1,w))
ds = [-1]*n
dq = deque([0])
ds[0] = 0
while dq:
  t = dq.popleft()
  for i in g[t]:
    if ds[i[0]] == -1:
      ds[i[0]] = ds[t] + i[1]
      dq.append((i[0]))
for i in ds:
  if i%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) [] g = [[] for _ in range(n)] g [[] for _ in range(n)] for i in range(n-1):
  u, v, w = map(int, input().split())
  g[u-1].append((v-1,w))
  g[v-1].append((u-1,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 g[u-1].append((v-1,w)) [u-1].append [u-1] g u-1 u 1 append (v-1,w) v-1 v 1 w g[v-1].append((u-1,w)) [v-1].append [v-1] g v-1 v 1 append (u-1,w) u-1 u 1 w ds = [-1]*n ds [-1]*n [-1] -1 n dq = deque([0]) dq deque([0]) deque [0] 0 ds[0] = 0 ds[0] ds 0 0 while dq:
  t = dq.popleft()
  for i in g[t]:
    if ds[i[0]] == -1:
      ds[i[0]] = ds[t] + i[1]
      dq.append((i[0])) dq t = dq.popleft() t dq.popleft() dq.popleft dq popleft for i in g[t]:
    if ds[i[0]] == -1:
      ds[i[0]] = ds[t] + i[1]
      dq.append((i[0])) i g[t] g t if ds[i[0]] == -1:
      ds[i[0]] = ds[t] + i[1]
      dq.append((i[0])) ds[i[0]] == -1 ds[i[0]] ds i[0] i 0 -1 ds[i[0]] = ds[t] + i[1] ds[i[0]] ds i[0] i 0 ds[t] + i[1] ds[t] ds t i[1] i 1 dq.append((i[0])) dq.append dq append i[0] i 0 for i in ds:
  if i%2 == 0:
    print(0)
  else:
    print(1) i ds if i%2 == 0:
    print(0)
  else:
    print(1) i%2 == 0 i%2 i 2 0 print(0) print 0 print(1) print 1 u, v, w = map(int, input().split()) map(int, input().split()) u n = int(input()) int(input()) n v, w = map(int, input().split()) map(int, input().split()) v t = dq.popleft() dq.popleft() t g = [[] for _ in range(n)] [[] for _ in range(n)] g dq = deque([0]) deque([0]) dq ds = [-1]*n [-1]*n ds w = map(int, input().split()) map(int, input().split()) w
from collections import deque
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
  u, v, w = map(int, input().split())
  g[u-1].append((v-1,w))
  g[v-1].append((u-1,w))
ds = [-1]*n
dq = deque([0])
ds[0] = 0
while dq:
  t = dq.popleft()
  for i in g[t]:
    if ds[i[0]] == -1:
      ds[i[0]] = ds[t] + i[1]
      dq.append((i[0]))
for i in ds:
  if i%2 == 0:
    print(0)
  else:
    print(1)