from collections import deque



N = int(eval(input()))

edge = [[] for _ in range(N)]

for _ in range(N-1):

    u, v, w = list(map(int, input().split()))

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

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

    

d = [0]*(N)



q = deque()

q.append([0, 0])

visited = [0]*(N)

while q:

    temp = q.pop()

    for L in edge[temp[0]]:

        if visited[L[0]] == 0:

            d[L[0]] = L[1] + temp[1]

            q.append([L[0], d[L[0]]])

            visited[L[0]] = 1

            

for i in range(N):

    print((d[i]%2))
from collections import deque

N = int(eval(input()))

E = [[] for _ in range(N)]

for _ in range(N-1):

    u,v,w = list(map(int, input().split()))

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

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



ans = [-1]*N

ans[0] = 0

q = deque()

q.append((0, 0))

while q:

    temp = q.popleft()

    u = temp[0]

    w = temp[1]

    for e in E[u]:

        if ans[e[0]] >= 0:

            continue

        if w+e[1] & 1 == 0:

            ans[e[0]] = 0

        else:

            ans[e[0]] = 1

        q.append((e[0], w+e[1]))



for a in ans:

    print(a)
from collections import deque

N = int(eval(input()))
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    edge[u - 1].append([v - 1, w])
    edge[v - 1].append([u - 1, w])
d = [0] * (N)
q = deque()
q.append([0, 0])
visited = [0] * (N)
while q:
    temp = q.pop()
    for L in edge[temp[0]]:
        if visited[L[0]] == 0:
            d[L[0]] = L[1] + temp[1]
            q.append([L[0], d[L[0]]])
            visited[L[0]] = 1
for i in range(N):
    print((d[i] % 2))

from collections import deque

N = int(eval(input()))
E = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    E[u - 1].append((v - 1, w))
    E[v - 1].append((u - 1, w))
ans = [-1] * N
ans[0] = 0
q = deque()
q.append((0, 0))
while q:
    temp = q.popleft()
    u = temp[0]
    w = temp[1]
    for e in E[u]:
        if ans[e[0]] >= 0:
            continue
        if w + e[1] & 1 == 0:
            ans[e[0]] = 0
        else:
            ans[e[0]] = 1
        q.append((e[0], w + e[1]))
for a in ans:
    print(a)

-edge = [[] for _ in range(N)] +E = [[] for _ in range(N)] -    edge[u - 1].append([v - 1, w]) -    edge[v - 1].append([u - 1, w]) -d = [0] * (N) +    E[u - 1].append((v - 1, w)) +    E[v - 1].append((u - 1, w)) +ans = [-1] * N +ans[0] = 0 -q.append([0, 0]) -visited = [0] * (N) +q.append((0, 0)) -    temp = q.pop() -    for L in edge[temp[0]]: -        if visited[L[0]] == 0: -            d[L[0]] = L[1] + temp[1] -            q.append([L[0], d[L[0]]]) -            visited[L[0]] = 1 -for i in range(N): -    print((d[i] % 2)) +    temp = q.popleft() +    u = temp[0] +    w = temp[1] +    for e in E[u]: +        if ans[e[0]] >= 0: +            continue +        if w + e[1] & 1 == 0: +            ans[e[0]] = 0 +        else: +            ans[e[0]] = 1 +        q.append((e[0], w + e[1])) +for a in ans: +    print(a)