N = int(eval(input()))

q = []

c = [0 for i in range(N)]

l = [0 for i in range(N)]

A = [[] for i in range(N)]

W = [[] for i in range(N)]



for i in range(N-1):

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

	u = u - 1

	v = v - 1

	

	A[u].append(v)

	A[v].append(u)

	W[u].append(w)

	W[v].append(w)



q.append(0)

while len(q):

	i = q.pop(0)

	c[i] = 1

	k = 0

	for j in A[i]:

		if c[j] == 0:

			q.append(j)

			l[j] = l[i] + W[i][k]

		k = k + 1



for i in l:

	print(('{}'.format(i%2)))

	
import sys

input = sys.stdin.readline

'''

allinputs = iter(input().splitlines())

input = lambda : next(allinputs)

#'''



N = int(eval(input()))

q = []

c = [0] * N

l = [0] * N

A = [[] for i in range(N)]

W = [[] for i in range(N)]



for i in range(N-1):

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

	u -= 1

	v -= 1

	

	A[u].append(v)

	A[v].append(u)

	W[u].append(w)

	W[v].append(w)



q.append(0)

while len(q):

	i = q.pop(0)

	c[i] = 1

	k = 0

	for j in A[i]:

		if c[j] == 0:

			q.append(j)

			l[j] = l[i] + W[i][k]

		k += 1



for i in l:

	print(('{}'.format(i%2)))

	
N = int(eval(input()))
q = []
c = [0 for i in range(N)]
l = [0 for i in range(N)]
A = [[] for i in range(N)]
W = [[] for i in range(N)]
for i in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u = u - 1
    v = v - 1
    A[u].append(v)
    A[v].append(u)
    W[u].append(w)
    W[v].append(w)
q.append(0)
while len(q):
    i = q.pop(0)
    c[i] = 1
    k = 0
    for j in A[i]:
        if c[j] == 0:
            q.append(j)
            l[j] = l[i] + W[i][k]
        k = k + 1
for i in l:
    print(("{}".format(i % 2)))

import sys

input = sys.stdin.readline
"""
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#"""
N = int(eval(input()))
q = []
c = [0] * N
l = [0] * N
A = [[] for i in range(N)]
W = [[] for i in range(N)]
for i in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    A[u].append(v)
    A[v].append(u)
    W[u].append(w)
    W[v].append(w)
q.append(0)
while len(q):
    i = q.pop(0)
    c[i] = 1
    k = 0
    for j in A[i]:
        if c[j] == 0:
            q.append(j)
            l[j] = l[i] + W[i][k]
        k += 1
for i in l:
    print(("{}".format(i % 2)))

+import sys + +input = sys.stdin.readline +""" +allinputs = iter(input().splitlines()) +input = lambda : next(allinputs) +#""" -c = [0 for i in range(N)] -l = [0 for i in range(N)] +c = [0] * N +l = [0] * N -    u = u - 1 -    v = v - 1 +    u -= 1 +    v -= 1 -        k = k + 1 +        k += 1