n = int(input())
visited = [False] * (n + 1)
distance = [0] * (n + 1)
prev = [0] * (n + 1)

from collections import defaultdict, deque
d = defaultdict(list)

for _ in range(n-1):
    u,v,w = list(map(int, input().split()))
    d[u].append((v, w))
    d[v].append((u, w))

q = deque([1])
while q:
    node = q.popleft()
    visited[node] = True
    for next_node, next_dist in d[node]:
        if not visited[next_node]:
            q.append(next_node)
            # 距離を更新
            distance[next_node] = distance[node] + next_dist
    
# print(distance)
for dist in distance[1:]:
    print(dist%2) n = int(input()) n int(input()) int input() input visited = [False] * (n + 1) visited [False] * (n + 1) [False] False n + 1 n 1 distance = [0] * (n + 1) distance [0] * (n + 1) [0] 0 n + 1 n 1 prev = [0] * (n + 1) prev [0] * (n + 1) [0] 0 n + 1 n 1 from collections import defaultdict, deque d = defaultdict(list) d defaultdict(list) defaultdict list for _ in range(n-1):
    u,v,w = list(map(int, input().split()))
    d[u].append((v, w))
    d[v].append((u, w)) _ range(n-1) range n-1 n 1 u,v,w = list(map(int, input().split())) u list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split v w d[u].append((v, w)) [u].append [u] d u append (v, w) v w d[v].append((u, w)) [v].append [v] d v append (u, w) u w q = deque([1]) q deque([1]) deque [1] 1 while q:
    node = q.popleft()
    visited[node] = True
    for next_node, next_dist in d[node]:
        if not visited[next_node]:
            q.append(next_node)
            # 距離を更新
            distance[next_node] = distance[node] + next_dist
    
# print(distance) q node = q.popleft() node q.popleft() q.popleft q popleft visited[node] = True visited[node] visited node True for next_node, next_dist in d[node]:
        if not visited[next_node]:
            q.append(next_node)
            # 距離を更新
            distance[next_node] = distance[node] + next_dist
    
# print(distance) next_node next_dist d[node] d node if not visited[next_node]:
            q.append(next_node)
            # 距離を更新
            distance[next_node] = distance[node] + next_dist
    
# print(distance) not visited[next_node] visited[next_node] visited next_node q.append(next_node) q.append q append next_node distance[next_node] = distance[node] + next_dist distance[next_node] distance next_node distance[node] + next_dist distance[node] distance node next_dist for dist in distance[1:]:
    print(dist%2) dist distance[1:] distance 1: 1 print(dist%2) print dist%2 dist 2 visited = [False] * (n + 1) [False] * (n + 1) visited u,v,w = list(map(int, input().split())) list(map(int, input().split())) u w = list(map(int, input().split())) list(map(int, input().split())) w node = q.popleft() q.popleft() node prev = [0] * (n + 1) [0] * (n + 1) prev distance = [0] * (n + 1) [0] * (n + 1) distance d = defaultdict(list) defaultdict(list) d v,w = list(map(int, input().split())) list(map(int, input().split())) v q = deque([1]) deque([1]) q n = int(input()) int(input()) n
n = int(input())
visited = [False] * (n + 1)
distance = [0] * (n + 1)
prev = [0] * (n + 1)

from collections import defaultdict, deque
d = defaultdict(list)

for _ in range(n-1):
    u,v,w = list(map(int, input().split()))
    d[u].append((v, w))
    d[v].append((u, w))

q = deque([1])
while q:
    node = q.popleft()
    visited[node] = True
    for next_node, next_dist in d[node]:
        if not visited[next_node]:
            q.append(next_node)
            # 距離を更新
            distance[next_node] = distance[node] + next_dist
    
# print(distance)
for dist in distance[1:]:
    print(dist%2)