N = int(input())
Tree = [[] for _ in range(N+1)]
UVW = []

for _ in range(N-1):
  u, v, w = map(int, input().split())
  Tree[u].append(v)
  Tree[v].append(u)
  UVW.append((u, v, w))

root = 1
parent = [0] * (N+1)
order = []
stack = [root]

while stack:
    x = stack.pop()
    order.append(x)
    for y in Tree[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

dis = [0] * (N+1)

for u, v, w in UVW:
  if parent[u] == v:
    dis[u] = w
  else:
    dis[v] = w

color = [-1] * (N+1)
color[root] = 0

for x in order:
  for y in Tree[x]:
    if y == parent[x]:
      continue
    if dis[y]%2 == 0:
      color[y] = color[x]
    else:
      color[y] = color[x] ^ 1

for i in range(1, N+1):
  print(color[i]) N = int(input()) N int(input()) int input() input [] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] Tree = [[] for _ in range(N+1)] Tree [[] for _ in range(N+1)] UVW = [] UVW [] for _ in range(N-1):
  u, v, w = map(int, input().split())
  Tree[u].append(v)
  Tree[v].append(u)
  UVW.append((u, v, 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 Tree[u].append(v) [u].append [u] Tree u append v Tree[v].append(u) [v].append [v] Tree v append u UVW.append((u, v, w)) UVW.append UVW append (u, v, w) u v w root = 1 root 1 parent = [0] * (N+1) parent [0] * (N+1) [0] 0 N+1 N 1 order = [] order [] stack = [root] stack [root] root while stack:
    x = stack.pop()
    order.append(x)
    for y in Tree[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y) stack x = stack.pop() x stack.pop() stack.pop stack pop order.append(x) order.append order append x for y in Tree[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y) y Tree[x] Tree x if y == parent[x]:
            continue
         y == parent[x] y parent[x] parent x continue parent[y] = x parent[y] parent y x stack.append(y) stack.append stack append y dis = [0] * (N+1) dis [0] * (N+1) [0] 0 N+1 N 1 for u, v, w in UVW:
  if parent[u] == v:
    dis[u] = w
  else:
    dis[v] = w u v w UVW if parent[u] == v:
    dis[u] = w
  else:
    dis[v] = w parent[u] == v parent[u] parent u v dis[u] = w dis[u] dis u w dis[v] = w dis[v] dis v w color = [-1] * (N+1) color [-1] * (N+1) [-1] -1 N+1 N 1 color[root] = 0 color[root] color root 0 for x in order:
  for y in Tree[x]:
    if y == parent[x]:
      continue
    if dis[y]%2 == 0:
      color[y] = color[x]
    else:
      color[y] = color[x] ^ 1 x order for y in Tree[x]:
    if y == parent[x]:
      continue
    if dis[y]%2 == 0:
      color[y] = color[x]
    else:
      color[y] = color[x] ^ 1 y Tree[x] Tree x if y == parent[x]:
      continue
     y == parent[x] y parent[x] parent x continue if dis[y]%2 == 0:
      color[y] = color[x]
    else:
      color[y] = color[x] ^ 1 dis[y]%2 == 0 dis[y]%2 dis[y] dis y 2 0 color[y] = color[x] color[y] color y color[x] color x color[y] = color[x] ^ 1 color[y] color y color[x] ^ 1 color[x] color x 1 for i in range(1, N+1):
  print(color[i]) i range(1, N+1) range 1 N+1 N 1 print(color[i]) print color[i] color i color = [-1] * (N+1) [-1] * (N+1) color x = stack.pop() stack.pop() x Tree = [[] for _ in range(N+1)] [[] for _ in range(N+1)] Tree order = [] [] order u, v, w = map(int, input().split()) map(int, input().split()) u w = map(int, input().split()) map(int, input().split()) w v, w = map(int, input().split()) map(int, input().split()) v UVW = [] [] UVW stack = [root] [root] stack root = 1 1 root dis = [0] * (N+1) [0] * (N+1) dis N = int(input()) int(input()) N parent = [0] * (N+1) [0] * (N+1) parent
N = int(input())
Tree = [[] for _ in range(N+1)]
UVW = []

for _ in range(N-1):
  u, v, w = map(int, input().split())
  Tree[u].append(v)
  Tree[v].append(u)
  UVW.append((u, v, w))

root = 1
parent = [0] * (N+1)
order = []
stack = [root]

while stack:
    x = stack.pop()
    order.append(x)
    for y in Tree[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

dis = [0] * (N+1)

for u, v, w in UVW:
  if parent[u] == v:
    dis[u] = w
  else:
    dis[v] = w

color = [-1] * (N+1)
color[root] = 0

for x in order:
  for y in Tree[x]:
    if y == parent[x]:
      continue
    if dis[y]%2 == 0:
      color[y] = color[x]
    else:
      color[y] = color[x] ^ 1

for i in range(1, N+1):
  print(color[i])