from collections import deque



N = int(eval(input()))

branch = [list(map(int, input().split())) for _ in range(N-1)]



adj = [[] for _ in range(N+1)]

for b in branch:

  adj[b[0]].append([b[1],b[2]])

  adj[b[1]].append([b[0],b[2]])



ans = [-1] * (N+1)

deq = deque()

deq.appendleft(1)

while len(deq) > 0:

  v = deq.pop()

  for u, w in adj[v]:

    if ans[u] == -1:

      deq.appendleft(u)

    if ans[v] == -1 and ans[u] == -1:

      if w % 2 == 0:

        ans[v] = 0

        ans[u] = 0

      else:

        ans[v] = 0

        ans[u] = 1

    elif ans[v] == 0:

      if w % 2 == 0:

        ans[u] = 0

      else:

        ans[u] = 1

    else:

      if w % 2 == 0:

        ans[u] = 1

      else:

        ans[u] = 0

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

  print((ans[i]))
from collections import deque



N = int(eval(input()))

branch = [list(map(int, input().split())) for _ in range(N-1)]



adj = [[] for _ in range(N+1)]

for b in branch:

  adj[b[0]].append([b[1],b[2]])

  adj[b[1]].append([b[0],b[2]])



ans = [-1] * (N+1)

deq = deque()

deq.appendleft(1)

while len(deq) > 0:

  v = deq.pop()

  for u, w in adj[v]:

    if ans[u] == -1:

      deq.appendleft(u)

    if ans[v] == -1 and ans[u] == -1:

      if w % 2 == 0:

        ans[v] = 0

        ans[u] = 0

      else:

        ans[v] = 0

        ans[u] = 1

    elif ans[v] == 0:

      if w % 2 == 0:

        ans[u] = 0

      else:

        ans[u] = 1

    else:

      if w % 2 == 0:

        ans[u] = 1

      else:

        ans[u] = 0

if N == 1:

  print((0))

else:

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

    print((ans[i]))
from collections import deque

N = int(eval(input()))
branch = [list(map(int, input().split())) for _ in range(N - 1)]
adj = [[] for _ in range(N + 1)]
for b in branch:
    adj[b[0]].append([b[1], b[2]])
    adj[b[1]].append([b[0], b[2]])
ans = [-1] * (N + 1)
deq = deque()
deq.appendleft(1)
while len(deq) > 0:
    v = deq.pop()
    for u, w in adj[v]:
        if ans[u] == -1:
            deq.appendleft(u)
        if ans[v] == -1 and ans[u] == -1:
            if w % 2 == 0:
                ans[v] = 0
                ans[u] = 0
            else:
                ans[v] = 0
                ans[u] = 1
        elif ans[v] == 0:
            if w % 2 == 0:
                ans[u] = 0
            else:
                ans[u] = 1
        else:
            if w % 2 == 0:
                ans[u] = 1
            else:
                ans[u] = 0
for i in range(1, N + 1):
    print((ans[i]))

from collections import deque

N = int(eval(input()))
branch = [list(map(int, input().split())) for _ in range(N - 1)]
adj = [[] for _ in range(N + 1)]
for b in branch:
    adj[b[0]].append([b[1], b[2]])
    adj[b[1]].append([b[0], b[2]])
ans = [-1] * (N + 1)
deq = deque()
deq.appendleft(1)
while len(deq) > 0:
    v = deq.pop()
    for u, w in adj[v]:
        if ans[u] == -1:
            deq.appendleft(u)
        if ans[v] == -1 and ans[u] == -1:
            if w % 2 == 0:
                ans[v] = 0
                ans[u] = 0
            else:
                ans[v] = 0
                ans[u] = 1
        elif ans[v] == 0:
            if w % 2 == 0:
                ans[u] = 0
            else:
                ans[u] = 1
        else:
            if w % 2 == 0:
                ans[u] = 1
            else:
                ans[u] = 0
if N == 1:
    print((0))
else:
    for i in range(1, N + 1):
        print((ans[i]))

-for i in range(1, N + 1): -    print((ans[i])) +if N == 1: +    print((0)) +else: +    for i in range(1, N + 1): +        print((ans[i]))