import collections



n=int(eval(input()))

ans=[0]*(n+1)

tree=[[] for _ in range(n+1)]

for i in range(n-1):

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

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

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

q=collections.deque([1])

check=[False]*(n+1)

check[1]=True

tmp=tree[1][0]

if tmp[1]%2==0:

  ans[1]=1

  ans[tmp[0]]=1

else:

  ans[1]=1

  ans[tmp[0]]=0

while 1:

  if len(q)==0:

    break

  tmp=q.popleft()

  for i in range(len(tree[tmp])):

    v,w=tree[tmp][i][0],tree[tmp][i][1]

    if check[v]:

      continue

    else:

      check[v]=True

      if w%2==0:

        ans[v]=ans[tmp]

      else:

        ans[v]=abs(1-ans[tmp])

      q.append(v)

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

  print((ans[i]))
import collections



n=int(eval(input()))

g=[[] for _ in range(n+1)] 

for _ in range(n-1):

  a,b,w=list(map(int,input().split()))

  g[a].append((b,w))

  g[b].append((a,w))

q=collections.deque()

q.append(1)

checked=[0]*(n+1)

ans=[0]*(n+1)

ans[1]=0

while len(q)!=0:

  v=q.popleft()

  checked[v]=1

  for u,w in g[v]:

    if checked[u]==0:

      if w%2==0:

        ans[u]=ans[v]

      else:

        ans[u]=ans[v]^1

      q.append(u)

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

  print((ans[i]))
import collections

n = int(eval(input()))
ans = [0] * (n + 1)
tree = [[] for _ in range(n + 1)]
for i in range(n - 1):
    u, v, w = list(map(int, input().split()))
    tree[u].append([v, w])
    tree[v].append([u, w])
q = collections.deque([1])
check = [False] * (n + 1)
check[1] = True
tmp = tree[1][0]
if tmp[1] % 2 == 0:
    ans[1] = 1
    ans[tmp[0]] = 1
else:
    ans[1] = 1
    ans[tmp[0]] = 0
while 1:
    if len(q) == 0:
        break
    tmp = q.popleft()
    for i in range(len(tree[tmp])):
        v, w = tree[tmp][i][0], tree[tmp][i][1]
        if check[v]:
            continue
        else:
            check[v] = True
            if w % 2 == 0:
                ans[v] = ans[tmp]
            else:
                ans[v] = abs(1 - ans[tmp])
            q.append(v)
for i in range(1, n + 1):
    print((ans[i]))

import collections

n = int(eval(input()))
g = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b, w = list(map(int, input().split()))
    g[a].append((b, w))
    g[b].append((a, w))
q = collections.deque()
q.append(1)
checked = [0] * (n + 1)
ans = [0] * (n + 1)
ans[1] = 0
while len(q) != 0:
    v = q.popleft()
    checked[v] = 1
    for u, w in g[v]:
        if checked[u] == 0:
            if w % 2 == 0:
                ans[u] = ans[v]
            else:
                ans[u] = ans[v] ^ 1
            q.append(u)
for i in range(1, n + 1):
    print((ans[i]))

+g = [[] for _ in range(n + 1)] +for _ in range(n - 1): +    a, b, w = list(map(int, input().split())) +    g[a].append((b, w)) +    g[b].append((a, w)) +q = collections.deque() +q.append(1) +checked = [0] * (n + 1) -tree = [[] for _ in range(n + 1)] -for i in range(n - 1): -    u, v, w = list(map(int, input().split())) -    tree[u].append([v, w]) -    tree[v].append([u, w]) -q = collections.deque([1]) -check = [False] * (n + 1) -check[1] = True -tmp = tree[1][0] -if tmp[1] % 2 == 0: -    ans[1] = 1 -    ans[tmp[0]] = 1 -else: -    ans[1] = 1 -    ans[tmp[0]] = 0 -while 1: -    if len(q) == 0: -        break -    tmp = q.popleft() -    for i in range(len(tree[tmp])): -        v, w = tree[tmp][i][0], tree[tmp][i][1] -        if check[v]: -            continue -        else: -            check[v] = True +ans[1] = 0 +while len(q) != 0: +    v = q.popleft() +    checked[v] = 1 +    for u, w in g[v]: +        if checked[u] == 0: -                ans[v] = ans[tmp] +                ans[u] = ans[v] -                ans[v] = abs(1 - ans[tmp]) -            q.append(v) +                ans[u] = ans[v] ^ 1 +            q.append(u)