from collections import deque



N = int(input())

edges = [[] for _ in range(N)]



for _ in range(N - 1):

    fr, to, c = map(int, input().split())

    fr -= 1

    to -= 1

    edges[fr].append((to, c))

    edges[to].append((fr, c))



depth = [-1] * N

st = deque([(0, -1, 0)])  # now, parent, dep



while st:

    now, parent, d = st.pop()



    depth[now] = d



    for to, c in edges[now]:

        if to == parent:

            continue

        st.append((to, now, d + c))



ans = [d % 2 for d in depth]

print(*ans, sep='\n')

from collections import deque

import sys

input = sys.stdin.buffer.readline



N = int(input())

INF = 10**18

edges = [[] for _ in range(N)]



for _ in range(N - 1):

    fr, to, w = map(int, input().split())

    fr -= 1

    to -= 1

    edges[fr].append((to, w))

    edges[to].append((fr, w))



dist = [INF] * N

que = deque([(0, 0)])



while que:

    now, d = que.pop()



    if dist[now] <= d:

        continue

    dist[now] = d

    for to, w in edges[now]:

        que.append((to, d + w))



ans = [dist[i] % 2 for i in range(N)]

print(*ans, sep='\n')

from collections import deque

N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, c))
    edges[to].append((fr, c))
depth = [-1] * N
st = deque([(0, -1, 0)])  # now, parent, dep
while st:
    now, parent, d = st.pop()
    depth[now] = d
    for to, c in edges[now]:
        if to == parent:
            continue
        st.append((to, now, d + c))
ans = [d % 2 for d in depth]
print(*ans, sep="\n")

from collections import deque
import sys

input = sys.stdin.buffer.readline
N = int(input())
INF = 10**18
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    fr, to, w = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, w))
    edges[to].append((fr, w))
dist = [INF] * N
que = deque([(0, 0)])
while que:
    now, d = que.pop()
    if dist[now] <= d:
        continue
    dist[now] = d
    for to, w in edges[now]:
        que.append((to, d + w))
ans = [dist[i] % 2 for i in range(N)]
print(*ans, sep="\n")

+import sys +input = sys.stdin.buffer.readline +INF = 10**18 -    fr, to, c = map(int, input().split()) +    fr, to, w = map(int, input().split()) -    edges[fr].append((to, c)) -    edges[to].append((fr, c)) -depth = [-1] * N -st = deque([(0, -1, 0)])  # now, parent, dep -while st: -    now, parent, d = st.pop() -    depth[now] = d -    for to, c in edges[now]: -        if to == parent: -            continue -        st.append((to, now, d + c)) -ans = [d % 2 for d in depth] +    edges[fr].append((to, w)) +    edges[to].append((fr, w)) +dist = [INF] * N +que = deque([(0, 0)]) +while que: +    now, d = que.pop() +    if dist[now] <= d: +        continue +    dist[now] = d +    for to, w in edges[now]: +        que.append((to, d + w)) +ans = [dist[i] % 2 for i in range(N)]