from collections import deque



N = int(eval(input()))

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

for _ in range(N-1):

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

    adj[u-1].append((v-1,w))

    adj[v-1].append((u-1,w))



color = [0]*N

visited = [0]*N

visited[0] = 1

q = deque()

q.append((0,0))



while q:

    v, l = q.pop()

    visited[v] = 1

    if l % 2 == 1:

        color[v] = 1

    for u, w in adj[v]:

        if not visited[u]:

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



for i in range(N):

    print((color[i]))

import sys

input = sys.stdin.readline

from collections import deque



N = int(eval(input()))

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

for _ in range(N-1):

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

    adj[u-1].append((v-1,w))

    adj[v-1].append((u-1,w))



color = [0]*N

visited = [0]*N

visited[0] = 1

q = deque()

q.append((0,0))



while q:

    v, l = q.pop()

    visited[v] = 1

    if l % 2 == 1:

        color[v] = 1

    for u, w in adj[v]:

        if not visited[u]:

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



for i in range(N):

    print((color[i]))

from collections import deque

N = int(eval(input()))
adj = [[] for i in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    adj[u - 1].append((v - 1, w))
    adj[v - 1].append((u - 1, w))
color = [0] * N
visited = [0] * N
visited[0] = 1
q = deque()
q.append((0, 0))
while q:
    v, l = q.pop()
    visited[v] = 1
    if l % 2 == 1:
        color[v] = 1
    for u, w in adj[v]:
        if not visited[u]:
            q.append((u, l + w))
for i in range(N):
    print((color[i]))

import sys

input = sys.stdin.readline
from collections import deque

N = int(eval(input()))
adj = [[] for i in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    adj[u - 1].append((v - 1, w))
    adj[v - 1].append((u - 1, w))
color = [0] * N
visited = [0] * N
visited[0] = 1
q = deque()
q.append((0, 0))
while q:
    v, l = q.pop()
    visited[v] = 1
    if l % 2 == 1:
        color[v] = 1
    for u, w in adj[v]:
        if not visited[u]:
            q.append((u, l + w))
for i in range(N):
    print((color[i]))

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