n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n - 1)]

from collections import defaultdict, deque
g = defaultdict(list)
for u, v, w in uvw:
    g[u-1].append((v - 1, w))
    g[v-1].append((u - 1, w))

ans = [-1] * n
ans[0] = 0
q = deque([0])

while q:
    cur = q.popleft()
    for target, w in g[cur]:
        if ans[target] == -1:
            if w % 2 == 0:
                ans[target] = ans[cur]
            else:
                ans[target] = 1 - ans[cur]
            q.append(target)

for a in ans:
    print(a) 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)] from collections import defaultdict, deque g = defaultdict(list) g defaultdict(list) defaultdict list for u, v, w in uvw:
    g[u-1].append((v - 1, w))
    g[v-1].append((u - 1, w)) u v w uvw g[u-1].append((v - 1, w)) [u-1].append [u-1] g u-1 u 1 append (v - 1, w) v - 1 v 1 w g[v-1].append((u - 1, w)) [v-1].append [v-1] g v-1 v 1 append (u - 1, w) u - 1 u 1 w ans = [-1] * n ans [-1] * n [-1] -1 n ans[0] = 0 ans[0] ans 0 0 q = deque([0]) q deque([0]) deque [0] 0 while q:
    cur = q.popleft()
    for target, w in g[cur]:
        if ans[target] == -1:
            if w % 2 == 0:
                ans[target] = ans[cur]
            else:
                ans[target] = 1 - ans[cur]
            q.append(target) q cur = q.popleft() cur q.popleft() q.popleft q popleft for target, w in g[cur]:
        if ans[target] == -1:
            if w % 2 == 0:
                ans[target] = ans[cur]
            else:
                ans[target] = 1 - ans[cur]
            q.append(target) target w g[cur] g cur if ans[target] == -1:
            if w % 2 == 0:
                ans[target] = ans[cur]
            else:
                ans[target] = 1 - ans[cur]
            q.append(target) ans[target] == -1 ans[target] ans target -1 if w % 2 == 0:
                ans[target] = ans[cur]
            else:
                ans[target] = 1 - ans[cur]
             w % 2 == 0 w % 2 w 2 0 ans[target] = ans[cur] ans[target] ans target ans[cur] ans cur ans[target] = 1 - ans[cur] ans[target] ans target 1 - ans[cur] 1 ans[cur] ans cur q.append(target) q.append q append target for a in ans:
    print(a) a ans print(a) print a q = deque([0]) deque([0]) q g = defaultdict(list) defaultdict(list) g cur = q.popleft() q.popleft() cur ans = [-1] * n [-1] * n ans n = int(input()) int(input()) n uvw = [list(map(int, input().split())) for _ in range(n - 1)] [list(map(int, input().split())) for _ in range(n - 1)] uvw
n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n - 1)]

from collections import defaultdict, deque
g = defaultdict(list)
for u, v, w in uvw:
    g[u-1].append((v - 1, w))
    g[v-1].append((u - 1, w))

ans = [-1] * n
ans[0] = 0
q = deque([0])

while q:
    cur = q.popleft()
    for target, w in g[cur]:
        if ans[target] == -1:
            if w % 2 == 0:
                ans[target] = ans[cur]
            else:
                ans[target] = 1 - ans[cur]
            q.append(target)

for a in ans:
    print(a)
