import sys

sys.setrecursionlimit(100000)



N = int(eval(input()))

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

for _ in range(N - 1):

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

    u -= 1

    v -= 1

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

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



C = [-1 for _ in range(N)]





def dfs(pos, color):

    C[pos] = color

    for e in G[pos]:

        if C[e[0]] != -1:

            continue

        # odd

        if e[1] & 1:

            c = 1 - color

            dfs(e[0], c)

        # even

        else:

            c = color

            dfs(e[0], c)





dfs(0, 0)

for i in range(N):

    print((C[i]))

import sys

input = sys.stdin.readline

sys.setrecursionlimit(100000)



N = int(eval(input()))

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

for _ in range(N - 1):

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

    u -= 1

    v -= 1

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

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



C = [-1 for _ in range(N)]





def dfs(pos, color):

    C[pos] = color

    for e in G[pos]:

        if C[e[0]] != -1:

            continue

        # odd

        if e[1] & 1:

            c = 1 - color

            dfs(e[0], c)

        # even

        else:

            c = color

            dfs(e[0], c)





dfs(0, 0)

for i in range(N):

    print((C[i]))

import sys

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


def dfs(pos, color):
    C[pos] = color
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            dfs(e[0], c)
        # even
        else:
            c = color
            dfs(e[0], c)


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

import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)
N = int(eval(input()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))
C = [-1 for _ in range(N)]


def dfs(pos, color):
    C[pos] = color
    for e in G[pos]:
        if C[e[0]] != -1:
            continue
        # odd
        if e[1] & 1:
            c = 1 - color
            dfs(e[0], c)
        # even
        else:
            c = color
            dfs(e[0], c)


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

+input = sys.stdin.readline