import sys

input = sys.stdin.readline

sys.setrecursionlimit(100000)



def dfs(v, p, c):

    color[v] = c

    for e in graph[v]:

        if e[0] == p: continue

        if e[1] % 2: dfs(e[0], v, 1-c)

        else: dfs(e[0], v, c)





n = int(eval(input()))

color = [-1 for _ in range(n)]

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



for i in range(n-1):

    u, v, w = [int(x) for x in input().split()]

    u, v = u - 1, v - 1

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

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



dfs(0, -1, 1)

for i in range(n):

    print((color[i]))
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 5)



def dfs(v, p, c):

    color[v] = c

    for e in graph[v]:

        if e[0] == p: continue

        if e[1] % 2: dfs(e[0], v, 1-c)

        else: dfs(e[0], v, c)





n = int(eval(input()))

color = [-1] * n

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



for _ in range(n-1):

    u, v, w = [int(x) for x in input().split()]

    u, v = u-1, v-1

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

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



dfs(0, -1, 1)

for c in color: print(c)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)


def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p:
            continue
        if e[1] % 2:
            dfs(e[0], v, 1 - c)
        else:
            dfs(e[0], v, c)


n = int(eval(input()))
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]
for i in range(n - 1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))
dfs(0, -1, 1)
for i in range(n):
    print((color[i]))

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**5)


def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p:
            continue
        if e[1] % 2:
            dfs(e[0], v, 1 - c)
        else:
            dfs(e[0], v, c)


n = int(eval(input()))
color = [-1] * n
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))
dfs(0, -1, 1)
for c in color:
    print(c)

-sys.setrecursionlimit(100000) +sys.setrecursionlimit(10**5) -color = [-1 for _ in range(n)] +color = [-1] * n -for i in range(n - 1): +for _ in range(n - 1): -for i in range(n): -    print((color[i])) +for c in color: +    print(c)