#!/usr/bin/env python3
from collections import deque

n = int(input())
g = [list() for _ in range(n)]
visited = [True] * n
coler = [0] * n
for _ in range(1, n):
    v1, v2, w = map(int, input().split())
    v1 -= 1
    v2 -= 1
    w %= 2
    g[v1].append((v2, w))
    g[v2].append((v1, w))

q = deque([0])
visited[0] = False
while q:
    a = q.pop()
    for v, w in g[a]:
        if visited[v]:
            visited[v] = False
            coler[v] = (coler[a] + w) % 2
            q.append(v)

print(*coler, sep="\n") from collections import deque n = int(input()) n int(input()) int input() input list() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list() list g = [list() for _ in range(n)] g [list() for _ in range(n)] visited = [True] * n visited [True] * n [True] True n coler = [0] * n coler [0] * n [0] 0 n for _ in range(1, n):
    v1, v2, w = map(int, input().split())
    v1 -= 1
    v2 -= 1
    w %= 2
    g[v1].append((v2, w))
    g[v2].append((v1, w)) _ range(1, n) range 1 n v1, v2, w = map(int, input().split()) v1 map(int, input().split()) map int input().split() ().split () input split v2 w v1 -= 1 v1 1 v2 -= 1 v2 1 w %= 2 w 2 g[v1].append((v2, w)) [v1].append [v1] g v1 append (v2, w) v2 w g[v2].append((v1, w)) [v2].append [v2] g v2 append (v1, w) v1 w q = deque([0]) q deque([0]) deque [0] 0 visited[0] = False visited[0] visited 0 False while q:
    a = q.pop()
    for v, w in g[a]:
        if visited[v]:
            visited[v] = False
            coler[v] = (coler[a] + w) % 2
            q.append(v) q a = q.pop() a q.pop() q.pop q pop for v, w in g[a]:
        if visited[v]:
            visited[v] = False
            coler[v] = (coler[a] + w) % 2
            q.append(v) v w g[a] g a if visited[v]:
            visited[v] = False
            coler[v] = (coler[a] + w) % 2
            q.append(v) visited[v] visited v visited[v] = False visited[v] visited v False coler[v] = (coler[a] + w) % 2 coler[v] coler v (coler[a] + w) % 2 coler[a] + w coler[a] coler a w 2 q.append(v) q.append q append v print(*coler, sep="\n") print *coler coler sep="\n" sep "\n" n = int(input()) int(input()) n coler = [0] * n [0] * n coler q = deque([0]) deque([0]) q v1 -= 1 1 v1 v1, v2, w = map(int, input().split()) map(int, input().split()) v1 w = map(int, input().split()) map(int, input().split()) w g = [list() for _ in range(n)] [list() for _ in range(n)] g visited = [True] * n [True] * n visited a = q.pop() q.pop() a v2, w = map(int, input().split()) map(int, input().split()) v2 v2 -= 1 1 v2 w %= 2 2 w
#!/usr/bin/env python3
from collections import deque

n = int(input())
g = [list() for _ in range(n)]
visited = [True] * n
coler = [0] * n
for _ in range(1, n):
    v1, v2, w = map(int, input().split())
    v1 -= 1
    v2 -= 1
    w %= 2
    g[v1].append((v2, w))
    g[v2].append((v1, w))

q = deque([0])
visited[0] = False
while q:
    a = q.pop()
    for v, w in g[a]:
        if visited[v]:
            visited[v] = False
            coler[v] = (coler[a] + w) % 2
            q.append(v)

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