import queue



import sys

input = sys.stdin.readline



N=int(input())

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



for i in range(N-1):

    u,vv,w=map(int,input().split())

    u-=1

    vv-=1

    adj[u].append((vv,w%2))

    adj[vv].append((u,w%2))



q=queue.Queue()

ans=[0]*N

q.put((0,-1,0))#v,par,col



while not q.empty():

    v,p,c=q.get()

    for i in range(len(adj[v])):

        n_v=adj[v][i][0]

        if n_v!=p:

            n_c=(c+adj[v][i][1])%2

            ans[n_v]=n_c

            q.put((n_v,v,n_c))

            

[print(ans[i]) for i in range(N)]

import sys

input = sys.stdin.readline



def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    mod=10**9+7

    N=I()

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

    for i in range(N-1):

        u,v,w=MI()

        u-=1

        v-=1

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

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

        

    

    ans=[-1]*N

    import queue

    

    q=queue.Queue()

    q.put(0)

    ans[0]=0

    

    while not q.empty():

        v=q.get()

        for nv,w in adj[v]:

            if ans[nv]==-1:

                if ans[v]==0 and w%2==0:

                    ans[nv]=0

                elif ans[v]==0 and w%2==1:

                    ans[nv]=1

                elif ans[v]==1 and w%2==0:

                    ans[nv]=1

                else:

                    ans[nv]=0

                q.put(nv)

                

    for i in range(N):

        print((ans[i]))

    

    



main()

import queue
import sys

input = sys.stdin.readline
N = int(input())
adj = [[] for _ in range(N)]
for i in range(N - 1):
    u, vv, w = map(int, input().split())
    u -= 1
    vv -= 1
    adj[u].append((vv, w % 2))
    adj[vv].append((u, w % 2))
q = queue.Queue()
ans = [0] * N
q.put((0, -1, 0))  # v,par,col
while not q.empty():
    v, p, c = q.get()
    for i in range(len(adj[v])):
        n_v = adj[v][i][0]
        if n_v != p:
            n_c = (c + adj[v][i][1]) % 2
            ans[n_v] = n_c
            q.put((n_v, v, n_c))
[print(ans[i]) for i in range(N)]

import sys

input = sys.stdin.readline


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    mod = 10**9 + 7
    N = I()
    adj = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = MI()
        u -= 1
        v -= 1
        adj[u].append((v, w))
        adj[v].append((u, w))
    ans = [-1] * N
    import queue

    q = queue.Queue()
    q.put(0)
    ans[0] = 0
    while not q.empty():
        v = q.get()
        for nv, w in adj[v]:
            if ans[nv] == -1:
                if ans[v] == 0 and w % 2 == 0:
                    ans[nv] = 0
                elif ans[v] == 0 and w % 2 == 1:
                    ans[nv] = 1
                elif ans[v] == 1 and w % 2 == 0:
                    ans[nv] = 1
                else:
                    ans[nv] = 0
                q.put(nv)
    for i in range(N):
        print((ans[i]))


main()

-import queue -N = int(input()) -adj = [[] for _ in range(N)] -for i in range(N - 1): -    u, vv, w = map(int, input().split()) -    u -= 1 -    vv -= 1 -    adj[u].append((vv, w % 2)) -    adj[vv].append((u, w % 2)) -q = queue.Queue() -ans = [0] * N -q.put((0, -1, 0))  # v,par,col -while not q.empty(): -    v, p, c = q.get() -    for i in range(len(adj[v])): -        n_v = adj[v][i][0] -        if n_v != p: -            n_c = (c + adj[v][i][1]) % 2 -            ans[n_v] = n_c -            q.put((n_v, v, n_c)) -[print(ans[i]) for i in range(N)] + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    N = I() +    adj = [[] for _ in range(N)] +    for i in range(N - 1): +        u, v, w = MI() +        u -= 1 +        v -= 1 +        adj[u].append((v, w)) +        adj[v].append((u, w)) +    ans = [-1] * N +    import queue + +    q = queue.Queue() +    q.put(0) +    ans[0] = 0 +    while not q.empty(): +        v = q.get() +        for nv, w in adj[v]: +            if ans[nv] == -1: +                if ans[v] == 0 and w % 2 == 0: +                    ans[nv] = 0 +                elif ans[v] == 0 and w % 2 == 1: +                    ans[nv] = 1 +                elif ans[v] == 1 and w % 2 == 0: +                    ans[nv] = 1 +                else: +                    ans[nv] = 0 +                q.put(nv) +    for i in range(N): +        print((ans[i])) + + +main()