import sys

input = sys.stdin.readline
N = int(input())
uvw = [list(map(int, input().split())) for _ in range(N - 1)]
g = [[] for _ in range(N)]
for a, b, w in uvw:
    g[a-1].append((b-1, w))
    g[b - 1].append((a - 1, w))

children = [[] for _ in range(N)]
colors = [None]*N
q = [(0, None, 0)]  # nodeid, parent, color
while len(q) > 0:
    v, p, c = q.pop()
    colors[v] = c
    for u, w in g[v]:
        if u != p:
            c_ = (c+(w%2))%2
            q.append((u, v, c_))
            children[v].append(u)
for c in colors:
    print(c) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input list(map(int, input().split())) for _ in range(N - 1) for _ in range(N - 1) _ range(N - 1) range N - 1 N 1 for _ in range(N - 1) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split uvw = [list(map(int, input().split())) for _ in range(N - 1)] uvw [list(map(int, input().split())) for _ in range(N - 1)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] g = [[] for _ in range(N)] g [[] for _ in range(N)] for a, b, w in uvw:
    g[a-1].append((b-1, w))
    g[b - 1].append((a - 1, w)) a b w uvw g[a-1].append((b-1, w)) [a-1].append [a-1] g a-1 a 1 append (b-1, w) b-1 b 1 w g[b - 1].append((a - 1, w)) [b - 1].append [b - 1] g b - 1 b 1 append (a - 1, w) a - 1 a 1 w [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] children = [[] for _ in range(N)] children [[] for _ in range(N)] colors = [None]*N colors [None]*N [None] None N q = [(0, None, 0)] q [(0, None, 0)] (0, None, 0) 0 None 0 while len(q) > 0:
    v, p, c = q.pop()
    colors[v] = c
    for u, w in g[v]:
        if u != p:
            c_ = (c+(w%2))%2
            q.append((u, v, c_))
            children[v].append(u) len(q) > 0 len(q) len q 0 v, p, c = q.pop() v q.pop() q.pop q pop p c colors[v] = c colors[v] colors v c for u, w in g[v]:
        if u != p:
            c_ = (c+(w%2))%2
            q.append((u, v, c_))
            children[v].append(u) u w g[v] g v if u != p:
            c_ = (c+(w%2))%2
            q.append((u, v, c_))
            children[v].append(u) u != p u p c_ = (c+(w%2))%2 c_ (c+(w%2))%2 c+(w%2) c w%2 w 2 2 q.append((u, v, c_)) q.append q append (u, v, c_) u v c_ children[v].append(u) [v].append [v] children v append u for c in colors:
    print(c) c colors print(c) print c children = [[] for _ in range(N)] [[] for _ in range(N)] children uvw = [list(map(int, input().split())) for _ in range(N - 1)] [list(map(int, input().split())) for _ in range(N - 1)] uvw q = [(0, None, 0)] [(0, None, 0)] q v, p, c = q.pop() q.pop() v colors = [None]*N [None]*N colors c = q.pop() q.pop() c N = int(input()) int(input()) N input = sys.stdin.readline sys.stdin.readline input c_ = (c+(w%2))%2 (c+(w%2))%2 c_ g = [[] for _ in range(N)] [[] for _ in range(N)] g p, c = q.pop() q.pop() p
import sys

input = sys.stdin.readline
N = int(input())
uvw = [list(map(int, input().split())) for _ in range(N - 1)]
g = [[] for _ in range(N)]
for a, b, w in uvw:
    g[a-1].append((b-1, w))
    g[b - 1].append((a - 1, w))

children = [[] for _ in range(N)]
colors = [None]*N
q = [(0, None, 0)]  # nodeid, parent, color
while len(q) > 0:
    v, p, c = q.pop()
    colors[v] = c
    for u, w in g[v]:
        if u != p:
            c_ = (c+(w%2))%2
            q.append((u, v, c_))
            children[v].append(u)
for c in colors:
    print(c)
