N = int(eval(input()))

nodes = [set() for _ in range(N)]

for _ in range(N - 1):

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

    u, v = (u - 1, v - 1)

    nodes[u].add((v, w))

    nodes[v].add((u, w))





ans = [-1] * N

q = [(0, 0, -1)]



while q:

    v, dist, parent = q.pop()



    if dist % 2 == 0:

        ans[v] = 0

    else:

        ans[v] = 1



    for u, w in nodes[v]:

        if u == parent:

            continue



        q.append((u, dist + w, v))



print(("\n".join(map(str, ans))))

import sys



N = int(eval(input()))

nodes = [set() for _ in range(N)]

for line in sys.stdin:

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

    u, v = (u - 1, v - 1)

    nodes[u].add((v, w))

    nodes[v].add((u, w))





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

q = [(0, 0, -1)]



while q:

    v, dist, parent = q.pop()



    if dist % 2 == 0:

        ans[v] = 0

    else:

        ans[v] = 1



    for u, w in nodes[v]:

        if u == parent:

            continue



        q.append((u, dist + w, v))



print(("\n".join(map(str, ans))))

N = int(eval(input()))
nodes = [set() for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u, v = (u - 1, v - 1)
    nodes[u].add((v, w))
    nodes[v].add((u, w))
ans = [-1] * N
q = [(0, 0, -1)]
while q:
    v, dist, parent = q.pop()
    if dist % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1
    for u, w in nodes[v]:
        if u == parent:
            continue
        q.append((u, dist + w, v))
print(("\n".join(map(str, ans))))

import sys

N = int(eval(input()))
nodes = [set() for _ in range(N)]
for line in sys.stdin:
    u, v, w = list(map(int, line.split()))
    u, v = (u - 1, v - 1)
    nodes[u].add((v, w))
    nodes[v].add((u, w))
ans = [-1 for _ in range(N)]
q = [(0, 0, -1)]
while q:
    v, dist, parent = q.pop()
    if dist % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1
    for u, w in nodes[v]:
        if u == parent:
            continue
        q.append((u, dist + w, v))
print(("\n".join(map(str, ans))))

+import sys + -for _ in range(N - 1): -    u, v, w = list(map(int, input().split())) +for line in sys.stdin: +    u, v, w = list(map(int, line.split())) -ans = [-1] * N +ans = [-1 for _ in range(N)]