import sys
sys.setrecursionlimit(100000)

N = int(input())
adj_list = { i: [] for i in range(N+1) }
for _ in range(N-1):
  u,v,w = map(int, input().split())
  adj_list[u].append([v,w])
  adj_list[v].append([u,w])

res = [None] * N
visited = [False] * (N+1)
def dfs(node, c, w):
  res[node-1] = c
  visited[node] = True

  for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw)

dfs(1, 0, 0)
for r in res: print(r) import sys sys sys.setrecursionlimit(100000) sys.setrecursionlimit sys setrecursionlimit 100000 N = int(input()) N int(input()) int input() input i: [] for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) i [] adj_list = { i: [] for i in range(N+1) } adj_list { i: [] for i in range(N+1) } for _ in range(N-1):
  u,v,w = map(int, input().split())
  adj_list[u].append([v,w])
  adj_list[v].append([u,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 adj_list[u].append([v,w]) [u].append [u] adj_list u append [v,w] v w adj_list[v].append([u,w]) [v].append [v] adj_list v append [u,w] u w res = [None] * N res [None] * N [None] None N visited = [False] * (N+1) visited [False] * (N+1) [False] False N+1 N 1 def dfs(node, c, w):
  res[node-1] = c
  visited[node] = True

  for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw) dfs res[node-1] = c res[node-1] res node-1 node 1 c visited[node] = True visited[node] visited node True for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw) nei nw adj_list[node] adj_list node if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw) not visited[nei] visited[nei] visited nei if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw) (w+nw)%2 == 0 (w+nw)%2 w+nw w nw 2 0 dfs(nei, 0, w+nw) dfs nei 0 w+nw w nw dfs(nei, 1, w+nw) dfs nei 1 w+nw w nw node node c c w w dfs(1, 0, 0) dfs 1 0 0 for r in res: print(r) r res u,v,w = map(int, input().split()) map(int, input().split()) u v,w = map(int, input().split()) map(int, input().split()) v visited = [False] * (N+1) [False] * (N+1) visited def dfs(node, c, w):
  res[node-1] = c
  visited[node] = True

  for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw) def dfs(node, c, w):
  res[node-1] = c
  visited[node] = True

  for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw) dfs N = int(input()) int(input()) N w = map(int, input().split()) map(int, input().split()) w adj_list = { i: [] for i in range(N+1) } { i: [] for i in range(N+1) } adj_list res = [None] * N [None] * N res
import sys
sys.setrecursionlimit(100000)

N = int(input())
adj_list = { i: [] for i in range(N+1) }
for _ in range(N-1):
  u,v,w = map(int, input().split())
  adj_list[u].append([v,w])
  adj_list[v].append([u,w])

res = [None] * N
visited = [False] * (N+1)
def dfs(node, c, w):
  res[node-1] = c
  visited[node] = True

  for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw)

dfs(1, 0, 0)
for r in res: print(r)