import sys

sys.setrecursionlimit(100000000)

N = int(eval(input()))

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

for _ in range(N-1):

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

  u -= 1

  v -= 1

  graph[u] += [[v, w]]

  graph[v] += [[u, w]]



color = [-1]*N 

def dfs(v, c):

  color[v] = c

  for next_v, w in graph[v]:

    if color[next_v] == c and w % 2 != 0:

      return 

    if color[next_v] == -1 and w % 2 == 0 and dfs(next_v, c) == False:

      return False

    if color[next_v] == -1 and w % 2 != 0 and dfs(next_v, abs(1-c)) == False:

      return False

  return True



dfs(0, 0)

for c in color:

  print(c)
import sys

sys.setrecursionlimit(1000000000)

input = sys.stdin.readline



N = int(eval(input()))

color = [-1]*N

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

for _ in range(N-1):

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

  u -= 1

  v -= 1

  graph[u] += [[v, w]]

  graph[v] += [[u, w]]



def dfs(u, c):

  color[u] = c

  for v, w in graph[u]:

    if color[v] == -1:

      if w % 2 == 0:

        dfs(v, c)

      else:

        dfs(v, abs(1-c))

  return



dfs(0, 0)

color = list(map(str, color))

print((*color))



import sys

sys.setrecursionlimit(100000000)
N = int(eval(input()))
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    graph[u] += [[v, w]]
    graph[v] += [[u, w]]
color = [-1] * N


def dfs(v, c):
    color[v] = c
    for next_v, w in graph[v]:
        if color[next_v] == c and w % 2 != 0:
            return
        if color[next_v] == -1 and w % 2 == 0 and dfs(next_v, c) == False:
            return False
        if color[next_v] == -1 and w % 2 != 0 and dfs(next_v, abs(1 - c)) == False:
            return False
    return True


dfs(0, 0)
for c in color:
    print(c)

import sys

sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
N = int(eval(input()))
color = [-1] * N
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    graph[u] += [[v, w]]
    graph[v] += [[u, w]]


def dfs(u, c):
    color[u] = c
    for v, w in graph[u]:
        if color[v] == -1:
            if w % 2 == 0:
                dfs(v, c)
            else:
                dfs(v, abs(1 - c))
    return


dfs(0, 0)
color = list(map(str, color))
print((*color))

-sys.setrecursionlimit(100000000) +sys.setrecursionlimit(1000000000) +input = sys.stdin.readline +color = [-1] * N -color = [-1] * N -def dfs(v, c): -    color[v] = c -    for next_v, w in graph[v]: -        if color[next_v] == c and w % 2 != 0: -            return -        if color[next_v] == -1 and w % 2 == 0 and dfs(next_v, c) == False: -            return False -        if color[next_v] == -1 and w % 2 != 0 and dfs(next_v, abs(1 - c)) == False: -            return False -    return True +def dfs(u, c): +    color[u] = c +    for v, w in graph[u]: +        if color[v] == -1: +            if w % 2 == 0: +                dfs(v, c) +            else: +                dfs(v, abs(1 - c)) +    return -for c in color: -    print(c) +color = list(map(str, color)) +print((*color))