from collections import deque

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

l = [[] for _ in range(n)]
for u, v, w in uvw:
    u, v = u-1, v-1
    l[u].append((v, w))
    l[v].append((u, w))

ans = [0] * n
parents = [-1] * n
q = deque([0])
while q:
    a = q.pop()
    for i, j in l[a]:
        if i == parents[a]:
            continue
        parents[i] = a
        q.append(i)
        ans[i] = ans[a] if j%2 == 0 else (ans[a]+1) % 2
for i in ans:
    print(i) from collections import deque 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) [] l = [[] for _ in range(n)] l [[] for _ in range(n)] for u, v, w in uvw:
    u, v = u-1, v-1
    l[u].append((v, w))
    l[v].append((u, w)) u v w uvw u, v = u-1, v-1 u u-1 u 1 v v-1 v 1 l[u].append((v, w)) [u].append [u] l u append (v, w) v w l[v].append((u, w)) [v].append [v] l v append (u, w) u w ans = [0] * n ans [0] * n [0] 0 n parents = [-1] * n parents [-1] * n [-1] -1 n q = deque([0]) q deque([0]) deque [0] 0 while q:
    a = q.pop()
    for i, j in l[a]:
        if i == parents[a]:
            continue
        parents[i] = a
        q.append(i)
        ans[i] = ans[a] if j%2 == 0 else (ans[a]+1) % 2 q a = q.pop() a q.pop() q.pop q pop for i, j in l[a]:
        if i == parents[a]:
            continue
        parents[i] = a
        q.append(i)
        ans[i] = ans[a] if j%2 == 0 else (ans[a]+1) % 2 i j l[a] l a if i == parents[a]:
            continue
         i == parents[a] i parents[a] parents a continue parents[i] = a parents[i] parents i a q.append(i) q.append q append i ans[i] = ans[a] if j%2 == 0 else (ans[a]+1) % 2 ans[i] ans i ans[a] if j%2 == 0 else (ans[a]+1) % 2 j%2 == 0 j%2 j 2 0 ans[a] ans a (ans[a]+1) % 2 ans[a]+1 ans[a] ans a 1 2 for i in ans:
    print(i) i ans print(i) print i ans = [0] * n [0] * n ans parents = [-1] * n [-1] * n parents n = int(input()) int(input()) n l = [[] for _ in range(n)] [[] for _ in range(n)] l a = q.pop() q.pop() a v = u-1, v-1 v-1 v uvw = [list(map(int, input().split())) for _ in range(n-1)] [list(map(int, input().split())) for _ in range(n-1)] uvw u, v = u-1, v-1 u-1 u q = deque([0]) deque([0]) q
from collections import deque

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

l = [[] for _ in range(n)]
for u, v, w in uvw:
    u, v = u-1, v-1
    l[u].append((v, w))
    l[v].append((u, w))

ans = [0] * n
parents = [-1] * n
q = deque([0])
while q:
    a = q.pop()
    for i, j in l[a]:
        if i == parents[a]:
            continue
        parents[i] = a
        q.append(i)
        ans[i] = ans[a] if j%2 == 0 else (ans[a]+1) % 2
for i in ans:
    print(i)