from collections import deque
from collections import defaultdict

n = int(input())

graph = defaultdict(set)
visited = [1] * 2 + [0] * (n - 1)
ans = [0] * (n + 1)

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

q = deque([1])

while q:
    curr = q.popleft()
    visited[curr] = 1
    for v, w in graph[curr]:
        if not visited[v]:
            ans[v] = (ans[curr] + w) % 2
            q.append(v)
        else:
            continue

print(*ans[1:], sep="\n") from collections import deque from collections import defaultdict n = int(input()) n int(input()) int input() input graph = defaultdict(set) graph defaultdict(set) defaultdict set visited = [1] * 2 + [0] * (n - 1) visited [1] * 2 + [0] * (n - 1) [1] * 2 [1] 1 2 [0] * (n - 1) [0] 0 n - 1 n 1 ans = [0] * (n + 1) ans [0] * (n + 1) [0] 0 n + 1 n 1 for _ in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].add((v, w))
    graph[v].add((u, w)) _ 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 graph[u].add((v, w)) [u].add [u] graph u add (v, w) v w graph[v].add((u, w)) [v].add [v] graph v add (u, w) u w q = deque([1]) q deque([1]) deque [1] 1 while q:
    curr = q.popleft()
    visited[curr] = 1
    for v, w in graph[curr]:
        if not visited[v]:
            ans[v] = (ans[curr] + w) % 2
            q.append(v)
        else:
            continue q curr = q.popleft() curr q.popleft() q.popleft q popleft visited[curr] = 1 visited[curr] visited curr 1 for v, w in graph[curr]:
        if not visited[v]:
            ans[v] = (ans[curr] + w) % 2
            q.append(v)
        else:
            continue v w graph[curr] graph curr if not visited[v]:
            ans[v] = (ans[curr] + w) % 2
            q.append(v)
        else:
            continue not visited[v] visited[v] visited v ans[v] = (ans[curr] + w) % 2 ans[v] ans v (ans[curr] + w) % 2 ans[curr] + w ans[curr] ans curr w 2 q.append(v) q.append q append v continue print(*ans[1:], sep="\n") print *ans[1:] ans[1:] ans 1: 1 sep="\n" sep "\n" ans = [0] * (n + 1) [0] * (n + 1) ans graph = defaultdict(set) defaultdict(set) graph w = map(int, input().split()) map(int, input().split()) w u, v, w = map(int, input().split()) map(int, input().split()) u visited = [1] * 2 + [0] * (n - 1) [1] * 2 + [0] * (n - 1) visited v, w = map(int, input().split()) map(int, input().split()) v n = int(input()) int(input()) n curr = q.popleft() q.popleft() curr q = deque([1]) deque([1]) q
from collections import deque
from collections import defaultdict

n = int(input())

graph = defaultdict(set)
visited = [1] * 2 + [0] * (n - 1)
ans = [0] * (n + 1)

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

q = deque([1])

while q:
    curr = q.popleft()
    visited[curr] = 1
    for v, w in graph[curr]:
        if not visited[v]:
            ans[v] = (ans[curr] + w) % 2
            q.append(v)
        else:
            continue

print(*ans[1:], sep="\n")