import sys

sys.setrecursionlimit(100000)



n=int(eval(input()))

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

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

anslist=[0 for i in range(n)]

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

for i in range(n-1):

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

        kilist[a-1].append((b,c))

        kilist[b-1].append((a,c))

def search(i):

        searchedlist[i-1]=1

        visitedlist[i-1]=1

        flag=0

        for j in kilist[i-1]:

            if visitedlist[j[0]-1]<0:

                visitedlist[j[0]-1]=1

                flag+=1

                anslist[j[0]-1]=anslist[i-1]+j[1]

        else:

            pass



        if flag>0:    

            for k in kilist[i-1]:

                if searchedlist[k[0]-1]==-1:

                    search(k[0])

search(2)

for i in anslist:

    print((i%2))

import sys

sys.setrecursionlimit(100000)

input=sys.stdin.readline

n=int(eval(input()))

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

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

anslist=[0 for i in range(n)]

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

for i in range(n-1):

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

        kilist[a-1].append((b,c))

        kilist[b-1].append((a,c))

def search(i):

        searchedlist[i-1]=1

        visitedlist[i-1]=1

        flag=0

        for j in kilist[i-1]:

            if visitedlist[j[0]-1]<0:

                visitedlist[j[0]-1]=1

                flag+=1

                anslist[j[0]-1]=anslist[i-1]+j[1]

        else:

            pass



        if flag>0:    

            for k in kilist[i-1]:

                if searchedlist[k[0]-1]==-1:

                    search(k[0])

search(2)

for i in anslist:

    print((i%2))

import sys

sys.setrecursionlimit(100000)
n = int(eval(input()))
visitedlist = [-1 for i in range(n)]
kilist = [[] for i in range(n)]
anslist = [0 for i in range(n)]
searchedlist = [-1 for i in range(n)]
for i in range(n - 1):
    a, b, c = list(map(int, input().split()))
    kilist[a - 1].append((b, c))
    kilist[b - 1].append((a, c))


def search(i):
    searchedlist[i - 1] = 1
    visitedlist[i - 1] = 1
    flag = 0
    for j in kilist[i - 1]:
        if visitedlist[j[0] - 1] < 0:
            visitedlist[j[0] - 1] = 1
            flag += 1
            anslist[j[0] - 1] = anslist[i - 1] + j[1]
    else:
        pass
    if flag > 0:
        for k in kilist[i - 1]:
            if searchedlist[k[0] - 1] == -1:
                search(k[0])


search(2)
for i in anslist:
    print((i % 2))

import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
n = int(eval(input()))
visitedlist = [-1 for i in range(n)]
kilist = [[] for i in range(n)]
anslist = [0 for i in range(n)]
searchedlist = [-1 for i in range(n)]
for i in range(n - 1):
    a, b, c = list(map(int, input().split()))
    kilist[a - 1].append((b, c))
    kilist[b - 1].append((a, c))


def search(i):
    searchedlist[i - 1] = 1
    visitedlist[i - 1] = 1
    flag = 0
    for j in kilist[i - 1]:
        if visitedlist[j[0] - 1] < 0:
            visitedlist[j[0] - 1] = 1
            flag += 1
            anslist[j[0] - 1] = anslist[i - 1] + j[1]
    else:
        pass
    if flag > 0:
        for k in kilist[i - 1]:
            if searchedlist[k[0] - 1] == -1:
                search(k[0])


search(2)
for i in anslist:
    print((i % 2))

+input = sys.stdin.readline