import sys
N = int(input())
G = [{} for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, sys.stdin.readline().split())
    u -= 1
    v -= 1
    G[u][v] = w
    G[v][u] = w

ans = [0] * N
todo = [(0, 0)]
done = set()
while todo:
    p, d = todo.pop()
    for np, dd in G[p].items():
        if not np in done:
            nd = d + dd
            ans[np] = nd % 2
            todo.append((np, nd))
    done.add(p)

for x in ans:
    print(x) import sys sys 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) {} G = [{} for _ in range(N)] G [{} for _ in range(N)] for _ in range(N - 1):
    u, v, w = map(int, sys.stdin.readline().split())
    u -= 1
    v -= 1
    G[u][v] = w
    G[v][u] = w _ range(N - 1) range N - 1 N 1 u, v, w = map(int, sys.stdin.readline().split()) u map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split v w u -= 1 u 1 v -= 1 v 1 G[u][v] = w G[u][v] [u] G u v w G[v][u] = w G[v][u] [v] G v u w ans = [0] * N ans [0] * N [0] 0 N todo = [(0, 0)] todo [(0, 0)] (0, 0) 0 0 done = set() done set() set while todo:
    p, d = todo.pop()
    for np, dd in G[p].items():
        if not np in done:
            nd = d + dd
            ans[np] = nd % 2
            todo.append((np, nd))
    done.add(p) todo p, d = todo.pop() p todo.pop() todo.pop todo pop d for np, dd in G[p].items():
        if not np in done:
            nd = d + dd
            ans[np] = nd % 2
            todo.append((np, nd))
     np dd G[p].items() [p].items [p] G p items if not np in done:
            nd = d + dd
            ans[np] = nd % 2
            todo.append((np, nd))
     not np in done np in done np done nd = d + dd nd d + dd d dd ans[np] = nd % 2 ans[np] ans np nd % 2 nd 2 todo.append((np, nd)) todo.append todo append (np, nd) np nd done.add(p) done.add done add p for x in ans:
    print(x) x ans print(x) print x u -= 1 1 u d = todo.pop() todo.pop() d v, w = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) v w = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) w done = set() set() done ans = [0] * N [0] * N ans p, d = todo.pop() todo.pop() p nd = d + dd d + dd nd v -= 1 1 v u, v, w = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) u todo = [(0, 0)] [(0, 0)] todo G = [{} for _ in range(N)] [{} for _ in range(N)] G N = int(input()) int(input()) N
import sys
N = int(input())
G = [{} for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, sys.stdin.readline().split())
    u -= 1
    v -= 1
    G[u][v] = w
    G[v][u] = w

ans = [0] * N
todo = [(0, 0)]
done = set()
while todo:
    p, d = todo.pop()
    for np, dd in G[p].items():
        if not np in done:
            nd = d + dd
            ans[np] = nd % 2
            todo.append((np, nd))
    done.add(p)

for x in ans:
    print(x)