N=int(eval(input()))

uvw= [list(map(int,input().split())) for _ in [0]*(N-1)]

connect=[[] for _ in [0]*N]

for u,v,w in uvw:

    connect[u-1].append((v-1,w))

    connect[v-1].append((u-1,w))

MAX=10**16

dist = [MAX]*N

dist[0]=0

q = [0]

while q:

    i = q.pop()

    for j,w in connect[i]:

        if dist[j] == MAX:

            dist[j] = dist[i]+w

            q.append(j)

for o in dist:

    print((o%2))
import heapq

N = int(input())

UVW = [list(map(int,input().split())) for _ in [0]*(N-1)]



E = [{} for _ in [0]*N]

for u,v,c in UVW:

    E[u-1][v-1] = c

    E[v-1][u-1] = c



def Dijkstra(N,E,start):

    d = [-1]*N

    q = [(0,start)]

    while q:

        ci,i = heapq.heappop(q)

        if d[i]!= -1:continue

        d[i] = ci

        for j,cj in E[i].items():

            if d[j]!=-1:continue

            heapq.heappush(q,(ci+cj,j))

    return d



d = Dijkstra(N,E,0)

print(*[l%2 for l in d],sep="\n")

N = int(eval(input()))
uvw = [list(map(int, input().split())) for _ in [0] * (N - 1)]
connect = [[] for _ in [0] * N]
for u, v, w in uvw:
    connect[u - 1].append((v - 1, w))
    connect[v - 1].append((u - 1, w))
MAX = 10**16
dist = [MAX] * N
dist[0] = 0
q = [0]
while q:
    i = q.pop()
    for j, w in connect[i]:
        if dist[j] == MAX:
            dist[j] = dist[i] + w
            q.append(j)
for o in dist:
    print((o % 2))

import heapq

N = int(input())
UVW = [list(map(int, input().split())) for _ in [0] * (N - 1)]
E = [{} for _ in [0] * N]
for u, v, c in UVW:
    E[u - 1][v - 1] = c
    E[v - 1][u - 1] = c


def Dijkstra(N, E, start):
    d = [-1] * N
    q = [(0, start)]
    while q:
        ci, i = heapq.heappop(q)
        if d[i] != -1:
            continue
        d[i] = ci
        for j, cj in E[i].items():
            if d[j] != -1:
                continue
            heapq.heappush(q, (ci + cj, j))
    return d


d = Dijkstra(N, E, 0)
print(*[l % 2 for l in d], sep="\n")

-N = int(eval(input())) -uvw = [list(map(int, input().split())) for _ in [0] * (N - 1)] -connect = [[] for _ in [0] * N] -for u, v, w in uvw: -    connect[u - 1].append((v - 1, w)) -    connect[v - 1].append((u - 1, w)) -MAX = 10**16 -dist = [MAX] * N -dist[0] = 0 -q = [0] -while q: -    i = q.pop() -    for j, w in connect[i]: -        if dist[j] == MAX: -            dist[j] = dist[i] + w -            q.append(j) -for o in dist: -    print((o % 2)) +import heapq + +N = int(input()) +UVW = [list(map(int, input().split())) for _ in [0] * (N - 1)] +E = [{} for _ in [0] * N] +for u, v, c in UVW: +    E[u - 1][v - 1] = c +    E[v - 1][u - 1] = c + + +def Dijkstra(N, E, start): +    d = [-1] * N +    q = [(0, start)] +    while q: +        ci, i = heapq.heappop(q) +        if d[i] != -1: +            continue +        d[i] = ci +        for j, cj in E[i].items(): +            if d[j] != -1: +                continue +            heapq.heappush(q, (ci + cj, j)) +    return d + + +d = Dijkstra(N, E, 0) +print(*[l % 2 for l in d], sep="\n")