import sys

sys.setrecursionlimit(1000000)

 

def dfs(l,d,k):

  for i in l[k]:

    if d[i[0]]==-1:

      d[i[0]]=d[k]+i[1]

      dfs(l,d,i[0])



n=int(eval(input()))

l=[list(map(int,input().split())) for i in range(n-1)]

connection=[[] for i in range(n)]

for i in range(n-1):

  connection[l[i][0]-1].append([l[i][1]-1,l[i][2]])

  connection[l[i][1]-1].append([l[i][0]-1,l[i][2]])

distance=[-1 for i in range(n)]

x=-1

for i in range(n-1):

  if len(connection[i])==1:

    x=i

    break

distance[x]=0

dfs(connection,distance,x)

for i in range(n):

  print((distance[i]%2))
n=int(eval(input()))

l=[list(map(int,input().split())) for i in range(n-1)]

connection=[[] for i in range(n)]

for i in range(n-1):

  connection[l[i][0]-1].append(l[i][1]-1)

  connection[l[i][1]-1].append(l[i][0]-1)

d={}

for i in range(n-1):

  d[(l[i][0]-1,l[i][1]-1)]=l[i][2]

  d[(l[i][1]-1,l[i][0]-1)]=l[i][2]



def bfs(v):

  distance=[-1]*n

  distance[v]=0

  next=[v]

  next2=set()

  visited=[-1]*n

  visitct=0

  while len(next)!=0 and visitct!=n:

    for i in range(len(next)):

      if visited[next[i]]==-1:

        visited[next[i]]=1

        visitct+=1

        for j in range(len(connection[next[i]])):

          if visited[connection[next[i]][j]]==-1:

            distance[connection[next[i]][j]]=distance[next[i]]+d[(next[i],connection[next[i]][j])]

            next2.add(connection[next[i]][j])

    next=list(next2)

    next2=set()

  return distance



ans=bfs(0)

for i in range(n):

  print((ans[i]%2))
import sys

sys.setrecursionlimit(1000000)


def dfs(l, d, k):
    for i in l[k]:
        if d[i[0]] == -1:
            d[i[0]] = d[k] + i[1]
            dfs(l, d, i[0])


n = int(eval(input()))
l = [list(map(int, input().split())) for i in range(n - 1)]
connection = [[] for i in range(n)]
for i in range(n - 1):
    connection[l[i][0] - 1].append([l[i][1] - 1, l[i][2]])
    connection[l[i][1] - 1].append([l[i][0] - 1, l[i][2]])
distance = [-1 for i in range(n)]
x = -1
for i in range(n - 1):
    if len(connection[i]) == 1:
        x = i
        break
distance[x] = 0
dfs(connection, distance, x)
for i in range(n):
    print((distance[i] % 2))

n = int(eval(input()))
l = [list(map(int, input().split())) for i in range(n - 1)]
connection = [[] for i in range(n)]
for i in range(n - 1):
    connection[l[i][0] - 1].append(l[i][1] - 1)
    connection[l[i][1] - 1].append(l[i][0] - 1)
d = {}
for i in range(n - 1):
    d[(l[i][0] - 1, l[i][1] - 1)] = l[i][2]
    d[(l[i][1] - 1, l[i][0] - 1)] = l[i][2]


def bfs(v):
    distance = [-1] * n
    distance[v] = 0
    next = [v]
    next2 = set()
    visited = [-1] * n
    visitct = 0
    while len(next) != 0 and visitct != n:
        for i in range(len(next)):
            if visited[next[i]] == -1:
                visited[next[i]] = 1
                visitct += 1
                for j in range(len(connection[next[i]])):
                    if visited[connection[next[i]][j]] == -1:
                        distance[connection[next[i]][j]] = (
                            distance[next[i]] + d[(next[i], connection[next[i]][j])]
                        )
                        next2.add(connection[next[i]][j])
        next = list(next2)
        next2 = set()
    return distance


ans = bfs(0)
for i in range(n):
    print((ans[i] % 2))

-import sys - -sys.setrecursionlimit(1000000) - - -def dfs(l, d, k): -    for i in l[k]: -        if d[i[0]] == -1: -            d[i[0]] = d[k] + i[1] -            dfs(l, d, i[0]) - - -    connection[l[i][0] - 1].append([l[i][1] - 1, l[i][2]]) -    connection[l[i][1] - 1].append([l[i][0] - 1, l[i][2]]) -distance = [-1 for i in range(n)] -x = -1 +    connection[l[i][0] - 1].append(l[i][1] - 1) +    connection[l[i][1] - 1].append(l[i][0] - 1) +d = {} -    if len(connection[i]) == 1: -        x = i -        break -distance[x] = 0 -dfs(connection, distance, x) +    d[(l[i][0] - 1, l[i][1] - 1)] = l[i][2] +    d[(l[i][1] - 1, l[i][0] - 1)] = l[i][2] + + +def bfs(v): +    distance = [-1] * n +    distance[v] = 0 +    next = [v] +    next2 = set() +    visited = [-1] * n +    visitct = 0 +    while len(next) != 0 and visitct != n: +        for i in range(len(next)): +            if visited[next[i]] == -1: +                visited[next[i]] = 1 +                visitct += 1 +                for j in range(len(connection[next[i]])): +                    if visited[connection[next[i]][j]] == -1: +                        distance[connection[next[i]][j]] = ( +                            distance[next[i]] + d[(next[i], connection[next[i]][j])] +                        ) +                        next2.add(connection[next[i]][j]) +        next = list(next2) +        next2 = set() +    return distance + + +ans = bfs(0) -    print((distance[i] % 2)) +    print((ans[i] % 2))