import heapq as hq
N = int(input())
L = [set() for _ in range(N)]
for _ in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    L[u].add((w, v))
    L[v].add((w, u))
# print(L)

INF = float('inf')
D = [INF]*N
D[0] = 0
task = []
hq.heapify(task)
for w, v in L[0]:
    hq.heappush(task, (w, v))
while task:
    w, v = hq.heappop(task)
    # print(v,w)
    if D[v] <= w:
        continue
    D[v] = w
    for y, x in L[v]:
        hq.heappush(task, (w+y, x))
# print(D)

for i in range(N):
    print(D[i] % 2) import heapq as hq heapq N = int(input()) N int(input()) int input() input set() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) set() set L = [set() for _ in range(N)] L [set() for _ in range(N)] for _ in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    L[u].add((w, v))
    L[v].add((w, u))
# print(L) _ range(N-1) range N-1 N 1 u, v, w = list(map(int, input().split())) u list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split v w u -= 1 u 1 v -= 1 v 1 L[u].add((w, v)) [u].add [u] L u add (w, v) w v L[v].add((w, u)) [v].add [v] L v add (w, u) w u INF = float('inf') INF float('inf') float 'inf' D = [INF]*N D [INF]*N [INF] INF N D[0] = 0 D[0] D 0 0 task = [] task [] hq.heapify(task) hq.heapify hq heapify task for w, v in L[0]:
    hq.heappush(task, (w, v)) w v L[0] L 0 hq.heappush(task, (w, v)) hq.heappush hq heappush task (w, v) w v while task:
    w, v = hq.heappop(task)
    # print(v,w)
    if D[v] <= w:
        continue
    D[v] = w
    for y, x in L[v]:
        hq.heappush(task, (w+y, x))
# print(D) task w, v = hq.heappop(task) w hq.heappop(task) hq.heappop hq heappop task v if D[v] <= w:
        continue
     D[v] <= w D[v] D v w continue D[v] = w D[v] D v w for y, x in L[v]:
        hq.heappush(task, (w+y, x))
# print(D) y x L[v] L v hq.heappush(task, (w+y, x)) hq.heappush hq heappush task (w+y, x) w+y w y x for i in range(N):
    print(D[i] % 2) i range(N) range N print(D[i] % 2) print D[i] % 2 D[i] D i 2 D = [INF]*N [INF]*N D v = hq.heappop(task) hq.heappop(task) v v, w = list(map(int, input().split())) list(map(int, input().split())) v v -= 1 1 v L = [set() for _ in range(N)] [set() for _ in range(N)] L w, v = hq.heappop(task) hq.heappop(task) w w = list(map(int, input().split())) list(map(int, input().split())) w u -= 1 1 u task = [] [] task u, v, w = list(map(int, input().split())) list(map(int, input().split())) u INF = float('inf') float('inf') INF N = int(input()) int(input()) N
import heapq as hq
N = int(input())
L = [set() for _ in range(N)]
for _ in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    L[u].add((w, v))
    L[v].add((w, u))
# print(L)

INF = float('inf')
D = [INF]*N
D[0] = 0
task = []
hq.heapify(task)
for w, v in L[0]:
    hq.heappush(task, (w, v))
while task:
    w, v = hq.heappop(task)
    # print(v,w)
    if D[v] <= w:
        continue
    D[v] = w
    for y, x in L[v]:
        hq.heappush(task, (w+y, x))
# print(D)

for i in range(N):
    print(D[i] % 2)
