import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

from collections import deque



N = int(eval(input()))

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

for i in range(N-1):

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

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

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



# 親を探索(頂点0を根)

parent = [0] * N

for v,_ in edge[0]:

    parent[v] = 0

open_list = deque([0])

while open_list:

    now = open_list.popleft()

    for v,w in edge[now]:

        if v == parent[now]:

            continue

        open_list.append(v)

        parent[v] = now





# 根からの距離を探索

path = [0] * N

open_list = deque([0])

while open_list:

    now = open_list.popleft()

    for v,w in edge[now]:

        if v == parent[now]:

            continue

        open_list.append(v)

        path[v] = path[now] + w



for i in path:

    if i % 2 == 0:

        print((0))

    else:

        print((1))
from collections import deque



N = int(eval(input()))

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

for _ in range(N-1):

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

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

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



dist = [-1] * N

dist[0] = 0

que = deque([0])

while que:

    u = que.popleft()

    d = dist[u]



    for v,w in edge[u]:

        if dist[v] > 0:

            continue

        dist[v] = d + w

        que.append(v)



for d in dist:

    if d % 2 == 0:

        print((0))

    else:

        print((1))
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import deque

N = int(eval(input()))
edge = [[] for _ in range(N)]
for i in range(N - 1):
    u, v, w = list(map(int, input().split()))
    edge[u - 1].append([v - 1, w])
    edge[v - 1].append([u - 1, w])
# 親を探索(頂点0を根)
parent = [0] * N
for v, _ in edge[0]:
    parent[v] = 0
open_list = deque([0])
while open_list:
    now = open_list.popleft()
    for v, w in edge[now]:
        if v == parent[now]:
            continue
        open_list.append(v)
        parent[v] = now
# 根からの距離を探索
path = [0] * N
open_list = deque([0])
while open_list:
    now = open_list.popleft()
    for v, w in edge[now]:
        if v == parent[now]:
            continue
        open_list.append(v)
        path[v] = path[now] + w
for i in path:
    if i % 2 == 0:
        print((0))
    else:
        print((1))

from collections import deque

N = int(eval(input()))
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    edge[u - 1].append((v - 1, w))
    edge[v - 1].append((u - 1, w))
dist = [-1] * N
dist[0] = 0
que = deque([0])
while que:
    u = que.popleft()
    d = dist[u]
    for v, w in edge[u]:
        if dist[v] > 0:
            continue
        dist[v] = d + w
        que.append(v)
for d in dist:
    if d % 2 == 0:
        print((0))
    else:
        print((1))

-import sys - -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -for i in range(N - 1): +for _ in range(N - 1): -    edge[u - 1].append([v - 1, w]) -    edge[v - 1].append([u - 1, w]) -# 親を探索(頂点0を根) -parent = [0] * N -for v, _ in edge[0]: -    parent[v] = 0 -open_list = deque([0]) -while open_list: -    now = open_list.popleft() -    for v, w in edge[now]: -        if v == parent[now]: +    edge[u - 1].append((v - 1, w)) +    edge[v - 1].append((u - 1, w)) +dist = [-1] * N +dist[0] = 0 +que = deque([0]) +while que: +    u = que.popleft() +    d = dist[u] +    for v, w in edge[u]: +        if dist[v] > 0: -        open_list.append(v) -        parent[v] = now -# 根からの距離を探索 -path = [0] * N -open_list = deque([0]) -while open_list: -    now = open_list.popleft() -    for v, w in edge[now]: -        if v == parent[now]: -            continue -        open_list.append(v) -        path[v] = path[now] + w -for i in path: -    if i % 2 == 0: +        dist[v] = d + w +        que.append(v) +for d in dist: +    if d % 2 == 0: