#coding: utf-8
from collections import defaultdict, deque

N = int(input())
G = {}
for i in range(1, N+1):
    G[i] = []

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

ret = [-1] * (N+1)

que = deque()
que.append((1, 0))

while len(que) > 0:
    node, distance = que[0]
    que.popleft()

    ret[node] = distance % 2
    for next_node, next_distance in G[node]:
        if ret[next_node] == -1:
            que.append((next_node, distance + next_distance))

for i in range(N):
    print(ret[i+1])
 from collections import defaultdict, deque N = int(input()) N int(input()) int input() input G = {} G {} for i in range(1, N+1):
    G[i] = [] i range(1, N+1) range 1 N+1 N 1 G[i] = [] G[i] G i [] for i in range(N-1):
    u, v, w = (int(n) for n in input().split())
    G[u].append((v, w))
    G[v].append((u, w)) i range(N-1) range N-1 N 1 int(n) for n in input().split() for n in input().split() n input().split() ().split () input split for n in input().split() int(n) int n u, v, w = (int(n) for n in input().split()) u (int(n) for n in input().split()) v w G[u].append((v, w)) [u].append [u] G u append (v, w) v w G[v].append((u, w)) [v].append [v] G v append (u, w) u w ret = [-1] * (N+1) ret [-1] * (N+1) [-1] -1 N+1 N 1 que = deque() que deque() deque que.append((1, 0)) que.append que append (1, 0) 1 0 while len(que) > 0:
    node, distance = que[0]
    que.popleft()

    ret[node] = distance % 2
    for next_node, next_distance in G[node]:
        if ret[next_node] == -1:
            que.append((next_node, distance + next_distance)) len(que) > 0 len(que) len que 0 node, distance = que[0] node que[0] que 0 distance que.popleft() que.popleft que popleft ret[node] = distance % 2 ret[node] ret node distance % 2 distance 2 for next_node, next_distance in G[node]:
        if ret[next_node] == -1:
            que.append((next_node, distance + next_distance)) next_node next_distance G[node] G node if ret[next_node] == -1:
            que.append((next_node, distance + next_distance)) ret[next_node] == -1 ret[next_node] ret next_node -1 que.append((next_node, distance + next_distance)) que.append que append (next_node, distance + next_distance) next_node distance + next_distance distance next_distance for i in range(N):
    print(ret[i+1]) i range(N) range N print(ret[i+1]) print ret[i+1] ret i+1 i 1 node, distance = que[0] que[0] node v, w = (int(n) for n in input().split()) (int(n) for n in input().split()) v ret = [-1] * (N+1) [-1] * (N+1) ret w = (int(n) for n in input().split()) (int(n) for n in input().split()) w G = {} {} G u, v, w = (int(n) for n in input().split()) (int(n) for n in input().split()) u que = deque() deque() que distance = que[0] que[0] distance N = int(input()) int(input()) N
#coding: utf-8
from collections import defaultdict, deque

N = int(input())
G = {}
for i in range(1, N+1):
    G[i] = []

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

ret = [-1] * (N+1)

que = deque()
que.append((1, 0))

while len(que) > 0:
    node, distance = que[0]
    que.popleft()

    ret[node] = distance % 2
    for next_node, next_distance in G[node]:
        if ret[next_node] == -1:
            que.append((next_node, distance + next_distance))

for i in range(N):
    print(ret[i+1])

