n=int(eval(input()))

c=[[] for i in range(n+1)]

d={}

for i in range(n-1):

    x,y,z=list(map(int,input().split()))

    c[x].append(y)

    c[y].append(x)

    d[x,y]=z

d[1,1]=0

stack=[1]

parent=[None]*(n+1)

while stack:

    i=stack.pop()

    for j in c[i]:

        if j==parent[i]:

            continue

        parent[j]=i

        d[1,j]=d[1,i]+d[tuple(sorted([i,j]))]

        stack.append(j)

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

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

input = sys.stdin.readline

n=int(eval(input()))

c=[[] for i in range(n+1)]

d={}

for i in range(n-1):

    x,y,z=list(map(int,input().split()))

    c[x].append(y)

    c[y].append(x)

    d[x,y]=z

d[1,1]=0

stack=[1]

parent=[None]*(n+1)

while stack:

    i=stack.pop()

    for j in c[i]:

        if j==parent[i]:

            continue

        parent[j]=i

        d[1,j]=d[1,i]+d[tuple(sorted([i,j]))]

        stack.append(j)

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

    print((d[1,i]%2))
n = int(eval(input()))
c = [[] for i in range(n + 1)]
d = {}
for i in range(n - 1):
    x, y, z = list(map(int, input().split()))
    c[x].append(y)
    c[y].append(x)
    d[x, y] = z
d[1, 1] = 0
stack = [1]
parent = [None] * (n + 1)
while stack:
    i = stack.pop()
    for j in c[i]:
        if j == parent[i]:
            continue
        parent[j] = i
        d[1, j] = d[1, i] + d[tuple(sorted([i, j]))]
        stack.append(j)
for i in range(1, n + 1):
    print((d[1, i] % 2))

import sys

input = sys.stdin.readline
n = int(eval(input()))
c = [[] for i in range(n + 1)]
d = {}
for i in range(n - 1):
    x, y, z = list(map(int, input().split()))
    c[x].append(y)
    c[y].append(x)
    d[x, y] = z
d[1, 1] = 0
stack = [1]
parent = [None] * (n + 1)
while stack:
    i = stack.pop()
    for j in c[i]:
        if j == parent[i]:
            continue
        parent[j] = i
        d[1, j] = d[1, i] + d[tuple(sorted([i, j]))]
        stack.append(j)
for i in range(1, n + 1):
    print((d[1, i] % 2))

+import sys + +input = sys.stdin.readline