from collections import deque

N = int(input())
edge = [[] for i in range(N)]
color = [-1] * N

for i in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append((v-1, w))
    edge[v-1].append((u-1, w))

q = deque([])
q.append((0,0))

while(q):
    cur, col = q.popleft()
    color[cur] = col
    for next, weight in edge[cur]:
        if color[next] != -1:
            continue

        if weight % 2:
            q.append((next, 1-col))
            color[next] = 1-col
        else:
            q.append((next, col))
            color[next] = col

print(*color, sep="\n") from collections import deque N = int(input()) N int(input()) int input() input [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] edge = [[] for i in range(N)] edge [[] for i in range(N)] color = [-1] * N color [-1] * N [-1] -1 N for i in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append((v-1, w))
    edge[v-1].append((u-1, w)) i range(N-1) range N-1 N 1 u, v, w = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v w edge[u-1].append((v-1, w)) [u-1].append [u-1] edge u-1 u 1 append (v-1, w) v-1 v 1 w edge[v-1].append((u-1, w)) [v-1].append [v-1] edge v-1 v 1 append (u-1, w) u-1 u 1 w q = deque([]) q deque([]) deque [] q.append((0,0)) q.append q append (0,0) 0 0 while(q):
    cur, col = q.popleft()
    color[cur] = col
    for next, weight in edge[cur]:
        if color[next] != -1:
            continue

        if weight % 2:
            q.append((next, 1-col))
            color[next] = 1-col
        else:
            q.append((next, col))
            color[next] = col q cur, col = q.popleft() cur q.popleft() q.popleft q popleft col color[cur] = col color[cur] color cur col for next, weight in edge[cur]:
        if color[next] != -1:
            continue

        if weight % 2:
            q.append((next, 1-col))
            color[next] = 1-col
        else:
            q.append((next, col))
            color[next] = col next weight edge[cur] edge cur if color[next] != -1:
            continue

         color[next] != -1 color[next] color next -1 continue if weight % 2:
            q.append((next, 1-col))
            color[next] = 1-col
        else:
            q.append((next, col))
            color[next] = col weight % 2 weight 2 q.append((next, 1-col)) q.append q append (next, 1-col) next 1-col 1 col color[next] = 1-col color[next] color next 1-col 1 col q.append((next, col)) q.append q append (next, col) next col color[next] = col color[next] color next col print(*color, sep="\n") print *color color sep="\n" sep "\n" col = q.popleft() q.popleft() col w = map(int, input().split()) map(int, input().split()) w color = [-1] * N [-1] * N color u, v, w = map(int, input().split()) map(int, input().split()) u q = deque([]) deque([]) q v, w = map(int, input().split()) map(int, input().split()) v cur, col = q.popleft() q.popleft() cur N = int(input()) int(input()) N edge = [[] for i in range(N)] [[] for i in range(N)] edge
from collections import deque

N = int(input())
edge = [[] for i in range(N)]
color = [-1] * N

for i in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append((v-1, w))
    edge[v-1].append((u-1, w))

q = deque([])
q.append((0,0))

while(q):
    cur, col = q.popleft()
    color[cur] = col
    for next, weight in edge[cur]:
        if color[next] != -1:
            continue

        if weight % 2:
            q.append((next, 1-col))
            color[next] = 1-col
        else:
            q.append((next, col))
            color[next] = col

print(*color, sep="\n")