from collections import deque
N = int(input())
UVW = [list(map(int, input().split())) for _ in range(N-1)]
G = [{} for _ in range(N+1)]
for u, v, w in UVW:
    G[u-1][v-1] = w
    G[v-1][u-1] = w
# print(G)


distance = [-1] * N

que = deque([(0, 0)])
while que:
    c, d = que.popleft()
    distance[c] = d

    for n, w in G[c].items():
        if distance[n] == -1:
            que.append((n, d+w))

# print(distance)
print(*[d % 2 for d in distance], sep='\n') from collections import deque N = int(input()) N int(input()) int input() input list(map(int, input().split())) for _ in range(N-1) for _ in range(N-1) _ range(N-1) range N-1 N 1 for _ in range(N-1) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split UVW = [list(map(int, input().split())) for _ in range(N-1)] UVW [list(map(int, input().split())) for _ in range(N-1)] {} for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) {} G = [{} for _ in range(N+1)] G [{} for _ in range(N+1)] for u, v, w in UVW:
    G[u-1][v-1] = w
    G[v-1][u-1] = w
# print(G) u v w UVW G[u-1][v-1] = w G[u-1][v-1] [u-1] G u-1 u 1 v-1 v 1 w G[v-1][u-1] = w G[v-1][u-1] [v-1] G v-1 v 1 u-1 u 1 w distance = [-1] * N distance [-1] * N [-1] -1 N que = deque([(0, 0)]) que deque([(0, 0)]) deque [(0, 0)] (0, 0) 0 0 while que:
    c, d = que.popleft()
    distance[c] = d

    for n, w in G[c].items():
        if distance[n] == -1:
            que.append((n, d+w))

# print(distance) que c, d = que.popleft() c que.popleft() que.popleft que popleft d distance[c] = d distance[c] distance c d for n, w in G[c].items():
        if distance[n] == -1:
            que.append((n, d+w))

# print(distance) n w G[c].items() [c].items [c] G c items if distance[n] == -1:
            que.append((n, d+w))

# print(distance) distance[n] == -1 distance[n] distance n -1 que.append((n, d+w)) que.append que append (n, d+w) n d+w d w d % 2 for d in distance for d in distance d distance for d in distance d % 2 d 2 print(*[d % 2 for d in distance], sep='\n') print *[d % 2 for d in distance] [d % 2 for d in distance] sep='\n' sep '\n' G = [{} for _ in range(N+1)] [{} for _ in range(N+1)] G d = que.popleft() que.popleft() d UVW = [list(map(int, input().split())) for _ in range(N-1)] [list(map(int, input().split())) for _ in range(N-1)] UVW c, d = que.popleft() que.popleft() c distance = [-1] * N [-1] * N distance que = deque([(0, 0)]) deque([(0, 0)]) que N = int(input()) int(input()) N
from collections import deque
N = int(input())
UVW = [list(map(int, input().split())) for _ in range(N-1)]
G = [{} for _ in range(N+1)]
for u, v, w in UVW:
    G[u-1][v-1] = w
    G[v-1][u-1] = w
# print(G)


distance = [-1] * N

que = deque([(0, 0)])
while que:
    c, d = que.popleft()
    distance[c] = d

    for n, w in G[c].items():
        if distance[n] == -1:
            que.append((n, d+w))

# print(distance)
print(*[d % 2 for d in distance], sep='\n')
