import sys

sys.setrecursionlimit(10**7)



N = int(eval(input()))

color = [-1] * N

G = [[] for _ in range(N)]

W = [[] for _ in range(N)]

for i in range(N-1):

  u, v, w = list(map(int, input().split()))

  G[u-1].append(v-1)

  G[v-1].append(u-1)

  W[u-1].append(w)

  W[v-1].append(w)



def dfs(v, cur):

  color[v] = cur

  for next_v, w in zip(G[v], W[v]):

    if color[next_v] != -1:

      continue

    if w % 2 == 0:

      dfs(next_v, cur)

    else:

      dfs(next_v, 1 - cur)

      

for i in range(N):

  if color[i] != -1:

    continue

  dfs(i, 0)

for i in range(N):

  print((color[i]))
import sys

sys.setrecursionlimit(10**7)



N = int(eval(input()))

color = [-1] * N

G = [[] for _ in range(N)]

for i in range(N-1):

  u, v, w = list(map(int, input().split()))

  G[u-1].append((v-1, w))

  G[v-1].append((u-1, w))



def dfs(v, cur):

  color[v] = cur

  for next_v, w in G[v]:

    if color[next_v] != -1:

      continue

    if w % 2 == 0:

      dfs(next_v, cur)

    else:

      dfs(next_v, 1 - cur)

      

dfs(0, 0)

for i in range(N):

  print((color[i]))
import sys

sys.setrecursionlimit(10**7)
N = int(eval(input()))
color = [-1] * N
G = [[] for _ in range(N)]
W = [[] for _ in range(N)]
for i in range(N - 1):
    u, v, w = list(map(int, input().split()))
    G[u - 1].append(v - 1)
    G[v - 1].append(u - 1)
    W[u - 1].append(w)
    W[v - 1].append(w)


def dfs(v, cur):
    color[v] = cur
    for next_v, w in zip(G[v], W[v]):
        if color[next_v] != -1:
            continue
        if w % 2 == 0:
            dfs(next_v, cur)
        else:
            dfs(next_v, 1 - cur)


for i in range(N):
    if color[i] != -1:
        continue
    dfs(i, 0)
for i in range(N):
    print((color[i]))

import sys

sys.setrecursionlimit(10**7)
N = int(eval(input()))
color = [-1] * N
G = [[] for _ in range(N)]
for i in range(N - 1):
    u, v, w = list(map(int, input().split()))
    G[u - 1].append((v - 1, w))
    G[v - 1].append((u - 1, w))


def dfs(v, cur):
    color[v] = cur
    for next_v, w in G[v]:
        if color[next_v] != -1:
            continue
        if w % 2 == 0:
            dfs(next_v, cur)
        else:
            dfs(next_v, 1 - cur)


dfs(0, 0)
for i in range(N):
    print((color[i]))

-W = [[] for _ in range(N)] -    G[u - 1].append(v - 1) -    G[v - 1].append(u - 1) -    W[u - 1].append(w) -    W[v - 1].append(w) +    G[u - 1].append((v - 1, w)) +    G[v - 1].append((u - 1, w)) -    for next_v, w in zip(G[v], W[v]): +    for next_v, w in G[v]: -for i in range(N): -    if color[i] != -1: -        continue -    dfs(i, 0) +dfs(0, 0)