from heapq import heappop, heappush

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

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 = [(0, 0)]
seen = set()
while todo:
    e, p = heappop(todo)
    if p in seen:
        continue
    seen.add(p)
    d[p] = e
    for pi, ei in a[p]:
        heappush(todo, (e + ei, pi))
for di in d:
    print(di % 2)
