import sys

sys.setrecursionlimit(10**9)



N = int(eval(input()))

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

for _ in range(N-1):

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

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

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



def dfs(vNow):

    useds[vNow] = True

    ans = anss[vNow]

    for v2, wt in adjL[vNow]:

        if useds[v2]: continue

        if wt % 2:  # 長さが奇数ならば、色を反転

            anss[v2] = 1-ans

        else:

            anss[v2] = ans

        dfs(v2)



useds = [False] * N

anss = [0] * N

anss[0] = 0

dfs(0)



print(('\n'.join(map(str, anss))))

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**9)



N = int(eval(input()))

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

for _ in range(N-1):

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

    u, v = u-1, v-1

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

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



colors = [0] * N

def dfs(vNow, vPar):

    color = colors[vNow]

    for v2, wt in adjL[vNow]:

        if v2 == vPar: continue

        if wt%2:

            colors[v2] = 1-color

        else:

            colors[v2] = color

        dfs(v2, vNow)



dfs(0, -1)



print(('\n'.join(map(str, colors))))

import sys

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


def dfs(vNow):
    useds[vNow] = True
    ans = anss[vNow]
    for v2, wt in adjL[vNow]:
        if useds[v2]:
            continue
        if wt % 2:  # 長さが奇数ならば、色を反転
            anss[v2] = 1 - ans
        else:
            anss[v2] = ans
        dfs(v2)


useds = [False] * N
anss = [0] * N
anss[0] = 0
dfs(0)
print(("\n".join(map(str, anss))))

import sys

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


def dfs(vNow, vPar):
    color = colors[vNow]
    for v2, wt in adjL[vNow]:
        if v2 == vPar:
            continue
        if wt % 2:
            colors[v2] = 1 - color
        else:
            colors[v2] = color
        dfs(v2, vNow)


dfs(0, -1)
print(("\n".join(map(str, colors))))

+input = sys.stdin.readline -    adjL[u - 1].append((v - 1, w)) -    adjL[v - 1].append((u - 1, w)) +    u, v = u - 1, v - 1 +    adjL[u].append((v, w)) +    adjL[v].append((u, w)) +colors = [0] * N -def dfs(vNow): -    useds[vNow] = True -    ans = anss[vNow] +def dfs(vNow, vPar): +    color = colors[vNow] -        if useds[v2]: +        if v2 == vPar: -        if wt % 2:  # 長さが奇数ならば、色を反転 -            anss[v2] = 1 - ans +        if wt % 2: +            colors[v2] = 1 - color -            anss[v2] = ans -        dfs(v2) +            colors[v2] = color +        dfs(v2, vNow) -useds = [False] * N -anss = [0] * N -anss[0] = 0 -dfs(0) -print(("\n".join(map(str, anss)))) +dfs(0, -1) +print(("\n".join(map(str, colors))))