import queue

N = int(eval(input()))

alist = [[] for _ in range(N+1)]

d = {}

q = queue.Queue()



for _ in range(N-1):

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

    alist[u].append(v)

    alist[v].append(u)

    d[(u, v)] = w % 2



q.put(1)

d[(1, 1)] = 0

seen = [False]*(N+1)

seen[1] = True



while not q.empty():

    s = q.get()

    for n in alist[s]:

        if not seen[n]:

            q.put(n)

            seen[n] = True

            d[(1, n)] = (d[1, s]+d[tuple(sorted([s, n]))]) % 2



for i in range(1, N+1):

    print((d[(1, i)]))

import queue

import sys



input = sys.stdin.readline

N = int(eval(input()))

alist = [[] for _ in range(N+1)]

d = {}

q = queue.Queue()



for _ in range(N-1):

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

    alist[u].append(v)

    alist[v].append(u)

    d[(u, v)] = w



q.put(1)

d[(1, 1)] = 0

seen = [False]*(N+1)

seen[1] = True



while not q.empty():

    s = q.get()

    for n in alist[s]:

        if not seen[n]:

            q.put(n)

            seen[n] = True

            d[(1, n)] = d[1, s]+d[tuple(sorted([s, n]))]



for i in range(1, N+1):

    print((d[(1, i)] % 2))

import queue

N = int(eval(input()))
alist = [[] for _ in range(N + 1)]
d = {}
q = queue.Queue()
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    alist[u].append(v)
    alist[v].append(u)
    d[(u, v)] = w % 2
q.put(1)
d[(1, 1)] = 0
seen = [False] * (N + 1)
seen[1] = True
while not q.empty():
    s = q.get()
    for n in alist[s]:
        if not seen[n]:
            q.put(n)
            seen[n] = True
            d[(1, n)] = (d[1, s] + d[tuple(sorted([s, n]))]) % 2
for i in range(1, N + 1):
    print((d[(1, i)]))

import queue
import sys

input = sys.stdin.readline
N = int(eval(input()))
alist = [[] for _ in range(N + 1)]
d = {}
q = queue.Queue()
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    alist[u].append(v)
    alist[v].append(u)
    d[(u, v)] = w
q.put(1)
d[(1, 1)] = 0
seen = [False] * (N + 1)
seen[1] = True
while not q.empty():
    s = q.get()
    for n in alist[s]:
        if not seen[n]:
            q.put(n)
            seen[n] = True
            d[(1, n)] = d[1, s] + d[tuple(sorted([s, n]))]
for i in range(1, N + 1):
    print((d[(1, i)] % 2))

+import sys +input = sys.stdin.readline -    d[(u, v)] = w % 2 +    d[(u, v)] = w -            d[(1, n)] = (d[1, s] + d[tuple(sorted([s, n]))]) % 2 +            d[(1, n)] = d[1, s] + d[tuple(sorted([s, n]))] -    print((d[(1, i)])) +    print((d[(1, i)] % 2))