import collections

N = int(eval(input()))

d = [0]*N

route = [set() for i in range(N)]

for i in range(N-1):

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

    u -= 1

    v -= 1

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

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

    d[u] += 1

    d[v] += 1

d = d.index(max(d))

q = collections.deque()

q.append((d, 0))



G = [0]*N



while(q):

    x, l = q.popleft()

    for v, w in route[x]:

        G[v] = w + l

        q.append((v, w+l))

        route[v].remove((x, w))

ans = [0]*N



for i in range(N):

    if i == d:

        continue

    if G[i] % 2 == 1:

        ans[i] = 1

for i in range(N):

    print((ans[i]))

import collections





def main():

    import sys

    input = sys.stdin.readline

    N = int(input())

    color = [-1]*N

    G = [set() for i in range(N)]

    for i in range(N-1):

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

        u -= 1

        v -= 1

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

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

    root = 0



    color[0] = 0

    q = collections.deque()

    q.append((root, 0))

    while(q):

        x, W = q.popleft()

        for y, w in G[x]:

            if color[y] < 0:

                if (W+w) % 2 == 0:

                    color[y] = 0

                else:

                    color[y] = 1

                q.append((y, W+w))

            else:

                continue

    print(*color, sep="\n")





main()

import collections

N = int(eval(input()))
d = [0] * N
route = [set() for i in range(N)]
for i in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    route[u].add((v, w))
    route[v].add((u, w))
    d[u] += 1
    d[v] += 1
d = d.index(max(d))
q = collections.deque()
q.append((d, 0))
G = [0] * N
while q:
    x, l = q.popleft()
    for v, w in route[x]:
        G[v] = w + l
        q.append((v, w + l))
        route[v].remove((x, w))
ans = [0] * N
for i in range(N):
    if i == d:
        continue
    if G[i] % 2 == 1:
        ans[i] = 1
for i in range(N):
    print((ans[i]))

import collections


def main():
    import sys

    input = sys.stdin.readline
    N = int(input())
    color = [-1] * N
    G = [set() for i in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        G[u].add((v, w))
        G[v].add((u, w))
    root = 0
    color[0] = 0
    q = collections.deque()
    q.append((root, 0))
    while q:
        x, W = q.popleft()
        for y, w in G[x]:
            if color[y] < 0:
                if (W + w) % 2 == 0:
                    color[y] = 0
                else:
                    color[y] = 1
                q.append((y, W + w))
            else:
                continue
    print(*color, sep="\n")


main()

-N = int(eval(input())) -d = [0] * N -route = [set() for i in range(N)] -for i in range(N - 1): -    u, v, w = list(map(int, input().split())) -    u -= 1 -    v -= 1 -    route[u].add((v, w)) -    route[v].add((u, w)) -    d[u] += 1 -    d[v] += 1 -d = d.index(max(d)) -q = collections.deque() -q.append((d, 0)) -G = [0] * N -while q: -    x, l = q.popleft() -    for v, w in route[x]: -        G[v] = w + l -        q.append((v, w + l)) -        route[v].remove((x, w)) -ans = [0] * N -for i in range(N): -    if i == d: -        continue -    if G[i] % 2 == 1: -        ans[i] = 1 -for i in range(N): -    print((ans[i])) + +def main(): +    import sys + +    input = sys.stdin.readline +    N = int(input()) +    color = [-1] * N +    G = [set() for i in range(N)] +    for i in range(N - 1): +        u, v, w = map(int, input().split()) +        u -= 1 +        v -= 1 +        G[u].add((v, w)) +        G[v].add((u, w)) +    root = 0 +    color[0] = 0 +    q = collections.deque() +    q.append((root, 0)) +    while q: +        x, W = q.popleft() +        for y, w in G[x]: +            if color[y] < 0: +                if (W + w) % 2 == 0: +                    color[y] = 0 +                else: +                    color[y] = 1 +                q.append((y, W + w)) +            else: +                continue +    print(*color, sep="\n") + + +main()