#!/usr/bin/env python3

n=int(eval(input()))

uvw=[list(map(int,input().split())) for i in range(n-1)]

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

color=[-1]*(n+1)

for u,v,w in uvw:

    graph[u].append((v,w))

    graph[v].append((u,w))



color[1]=1

ne=[1]

while ne:

    t=ne.pop()

    for v,w in graph[t]:

        if color[v]==-1:

            ne.append(v)

            color[v]=color[t] if w%2==0 else (color[t]+1)%2



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

    print((color[i]))
#!/usr/bin/env python3

import sys

input = lambda: sys.stdin.readline()[:-1]

sys.setrecursionlimit(10**8)





n = int(eval(input()))

uvw = [list(map(int, input().split())) for i in range(n-1)]

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

color = [-1]*(n+1)

for u, v, w in uvw:

    graph[u].append((v, w))

    graph[v].append((u, w))



color[1] = 1

ne = [1]

while ne:

    t = ne.pop()

    for v, w in graph[t]:

        if color[v] == -1:

            ne.append(v)

            color[v] = color[t] if w % 2 == 0 else (color[t]+1) % 2



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

    print((color[i]))

#!/usr/bin/env python3
n = int(eval(input()))
uvw = [list(map(int, input().split())) for i in range(n - 1)]
graph = [[] for i in range(n + 1)]
color = [-1] * (n + 1)
for u, v, w in uvw:
    graph[u].append((v, w))
    graph[v].append((u, w))
color[1] = 1
ne = [1]
while ne:
    t = ne.pop()
    for v, w in graph[t]:
        if color[v] == -1:
            ne.append(v)
            color[v] = color[t] if w % 2 == 0 else (color[t] + 1) % 2
for i in range(1, n + 1):
    print((color[i]))

#!/usr/bin/env python3
import sys

input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
n = int(eval(input()))
uvw = [list(map(int, input().split())) for i in range(n - 1)]
graph = [[] for i in range(n + 1)]
color = [-1] * (n + 1)
for u, v, w in uvw:
    graph[u].append((v, w))
    graph[v].append((u, w))
color[1] = 1
ne = [1]
while ne:
    t = ne.pop()
    for v, w in graph[t]:
        if color[v] == -1:
            ne.append(v)
            color[v] = color[t] if w % 2 == 0 else (color[t] + 1) % 2
for i in range(1, n + 1):
    print((color[i]))

+import sys + +input = lambda: sys.stdin.readline()[:-1] +sys.setrecursionlimit(10**8)