import sys

sys.setrecursionlimit(10**9)

N = int(eval(input()))

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

for _ in range(N-1):

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

    u -= 1

    v -= 1

    adjacent_list[u].append([v, w])

    adjacent_list[v].append([u, w])





colors = [-1]*N





def dfs(v, color):

    if colors[v] != -1:

        return

    colors[v] = color

    for adjacent_v in adjacent_list[v]:

        if adjacent_v[1] % 2 == 0:

            dfs(adjacent_v[0], color)

        else:

            dfs(adjacent_v[0], 1-color)



dfs(0,0)



#print(*colors)

for i in range(N):

    print((colors[i]))

import sys

sys.setrecursionlimit(10**9)

N = int(eval(input()))

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

for _ in range(N-1):

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

    u -= 1

    v -= 1

    adjacent_list[u].append([v, w])

    adjacent_list[v].append([u, w])





colors = [-1]*N





def dfs(v, color):

    if colors[v] != -1: # 探索済みでないかチェック。

        return

    colors[v] = color

    for adjacent_v in adjacent_list[v]:

        if adjacent_v[1] % 2 == 0:

            dfs(adjacent_v[0], color)

        else:

            dfs(adjacent_v[0], 1-color)



dfs(0,0)



#print(*colors)

for i in range(N):

    print((colors[i]))

import sys

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


def dfs(v, color):
    if colors[v] != -1:
        return
    colors[v] = color
    for adjacent_v in adjacent_list[v]:
        if adjacent_v[1] % 2 == 0:
            dfs(adjacent_v[0], color)
        else:
            dfs(adjacent_v[0], 1 - color)


dfs(0, 0)
# print(*colors)
for i in range(N):
    print((colors[i]))

import sys

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


def dfs(v, color):
    if colors[v] != -1:  # 探索済みでないかチェック。
        return
    colors[v] = color
    for adjacent_v in adjacent_list[v]:
        if adjacent_v[1] % 2 == 0:
            dfs(adjacent_v[0], color)
        else:
            dfs(adjacent_v[0], 1 - color)


dfs(0, 0)
# print(*colors)
for i in range(N):
    print((colors[i]))

-    if colors[v] != -1: +    if colors[v] != -1:  # 探索済みでないかチェック。