from collections import deque

n = int(input())
a = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    a[u - 1].append((v - 1, w))
    a[v - 1].append((u - 1, w))
d = [-1] * n
todo = deque([(0, 0)])
seen = set()
while todo:
    p, e = todo.popleft()
    if p in seen:
        continue
    seen.add(p)
    d[p] = e
    for pi, ei in a[p]:
        todo.append((pi, e + ei))
for di in d:
    print(di % 2) from collections import deque n = int(input()) n int(input()) int input() input [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] a = [[] for _ in range(n)] a [[] for _ in range(n)] for _ in range(n - 1):
    u, v, w = map(int, input().split())
    a[u - 1].append((v - 1, w))
    a[v - 1].append((u - 1, 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 a[u - 1].append((v - 1, w)) [u - 1].append [u - 1] a u - 1 u 1 append (v - 1, w) v - 1 v 1 w a[v - 1].append((u - 1, w)) [v - 1].append [v - 1] a v - 1 v 1 append (u - 1, w) u - 1 u 1 w d = [-1] * n d [-1] * n [-1] -1 n todo = deque([(0, 0)]) todo deque([(0, 0)]) deque [(0, 0)] (0, 0) 0 0 seen = set() seen set() set while todo:
    p, e = todo.popleft()
    if p in seen:
        continue
    seen.add(p)
    d[p] = e
    for pi, ei in a[p]:
        todo.append((pi, e + ei)) todo p, e = todo.popleft() p todo.popleft() todo.popleft todo popleft e if p in seen:
        continue
     p in seen p seen continue seen.add(p) seen.add seen add p d[p] = e d[p] d p e for pi, ei in a[p]:
        todo.append((pi, e + ei)) pi ei a[p] a p todo.append((pi, e + ei)) todo.append todo append (pi, e + ei) pi e + ei e ei for di in d:
    print(di % 2) di d print(di % 2) print di % 2 di 2 e = todo.popleft() todo.popleft() e u, v, w = map(int, input().split()) map(int, input().split()) u seen = set() set() seen a = [[] for _ in range(n)] [[] for _ in range(n)] a v, w = map(int, input().split()) map(int, input().split()) v d = [-1] * n [-1] * n d todo = deque([(0, 0)]) deque([(0, 0)]) todo n = int(input()) int(input()) n p, e = todo.popleft() todo.popleft() p w = map(int, input().split()) map(int, input().split()) w
from collections import deque

n = int(input())
a = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    a[u - 1].append((v - 1, w))
    a[v - 1].append((u - 1, w))
d = [-1] * n
todo = deque([(0, 0)])
seen = set()
while todo:
    p, e = todo.popleft()
    if p in seen:
        continue
    seen.add(p)
    d[p] = e
    for pi, ei in a[p]:
        todo.append((pi, e + ei))
for di in d:
    print(di % 2)
