n = int(eval(input()))

uvw = [0]*(n-1)

for i in range(n-1):

    uvw[i] = list(map(int,input().split()))

V = [[] for i in range(n+1)]

for u,v,w in uvw:

    V[u].append([v,w])

    V[v].append([u,w])

from collections import deque

q = deque([])

now = 1

reach = [0]*(n+1)

reach[now] = 2

q.append(now)

while q:

    x = q.popleft()

    for L in V[x]:

        if reach[L[0]] == 0:

            q.append(L[0])

            reach[L[0]] = reach[x] + L[1]

for A in reach[1:]:

    if A%2 == 0:

        print((0))

    else:

        print((1))
from collections import deque

n = int(eval(input()))

V = [[] for i in range(n+1)]

for i in range(n-1):

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

    V[u].append([v,w])

    V[v].append([u,w])

q = deque([])

dis = [-1]*(n+1)

q.append(1)

dis[1] = 0

while q:

    x = q.popleft()

    for y,z in V[x]:

        if dis[y] == -1:

            q.append(y)

            dis[y] = dis[x] + z

for i in range(1,n+1):

    if dis[i]%2 == 0:

        print((0))

    else:

        print((1))
n = int(eval(input()))
uvw = [0] * (n - 1)
for i in range(n - 1):
    uvw[i] = list(map(int, input().split()))
V = [[] for i in range(n + 1)]
for u, v, w in uvw:
    V[u].append([v, w])
    V[v].append([u, w])
from collections import deque

q = deque([])
now = 1
reach = [0] * (n + 1)
reach[now] = 2
q.append(now)
while q:
    x = q.popleft()
    for L in V[x]:
        if reach[L[0]] == 0:
            q.append(L[0])
            reach[L[0]] = reach[x] + L[1]
for A in reach[1:]:
    if A % 2 == 0:
        print((0))
    else:
        print((1))

from collections import deque

n = int(eval(input()))
V = [[] for i in range(n + 1)]
for i in range(n - 1):
    u, v, w = list(map(int, input().split()))
    V[u].append([v, w])
    V[v].append([u, w])
q = deque([])
dis = [-1] * (n + 1)
q.append(1)
dis[1] = 0
while q:
    x = q.popleft()
    for y, z in V[x]:
        if dis[y] == -1:
            q.append(y)
            dis[y] = dis[x] + z
for i in range(1, n + 1):
    if dis[i] % 2 == 0:
        print((0))
    else:
        print((1))

+from collections import deque + -uvw = [0] * (n - 1) +V = [[] for i in range(n + 1)] -    uvw[i] = list(map(int, input().split())) -V = [[] for i in range(n + 1)] -for u, v, w in uvw: +    u, v, w = list(map(int, input().split())) -from collections import deque - -now = 1 -reach = [0] * (n + 1) -reach[now] = 2 -q.append(now) +dis = [-1] * (n + 1) +q.append(1) +dis[1] = 0 -    for L in V[x]: -        if reach[L[0]] == 0: -            q.append(L[0]) -            reach[L[0]] = reach[x] + L[1] -for A in reach[1:]: -    if A % 2 == 0: +    for y, z in V[x]: +        if dis[y] == -1: +            q.append(y) +            dis[y] = dis[x] + z +for i in range(1, n + 1): +    if dis[i] % 2 == 0: