import sys

sys.setrecursionlimit(2**31-1)

input = sys.stdin.readline

write = lambda x: sys.stdout.write(str(x))

LMIIS = lambda : list(map(int,input().split()))

II = lambda : int(input())

dbg = lambda *something : print(*something) if DEBUG is True else 0

DEBUG = False



def main():



    N = II()

    t = [-1] * N





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

 

    reached = [False] * N

    for _ in range(N-1):

        u,v,w = LMIIS()

        u -=1

        v -=1

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

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

    dbg(E)

    t[E[0][0][0]] = 0



     

    def search(u):

        for v,w in E[u]:

            if t[v] == -1:

                t[v] = t[u] if w % 2 == 0 else t[u]^1

                search(v)

                



    search(E[0][0][0])



    for i in t:

        write(i)

        write(' ')













    pass

if __name__ == '__main__':

    main()

import sys

sys.setrecursionlimit(2**31-1)

input = sys.stdin.readline

write = lambda x: sys.stdout.write(str(x))

LMIIS = lambda : list(map(int,input().split()))

II = lambda : int(input())

dbg = lambda *something : print(*something) if DEBUG is True else 0

DEBUG = False



def main():



    N = II()

    t = [-1] * N





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

 

    reached = [False] * N

    for _ in range(N-1):

        u,v,w = LMIIS()

        u -=1

        v -=1

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

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

    dbg(E)

    t[E[0][0][0]] = 0



     

    # def search(u):

    #     for v,w in E[u]:

    #         if t[v] == -1:

    #             t[v] = t[u] if w % 2 == 0 else t[u]^1

    #             search(v)

                



    # search(E[0][0][0])

    reached = [False] * N

    q = [E[0][0][0]]

    while q:

        u = q.pop()

        reached[u] = True

        for v,w in E[u]:

            if reached[v] != True and  t[v] == -1:

                t[v] = t[u] if w % 2 == 0 else t[u]^1

                q.append(v)



                







    for i in t:

        write(i)

        write(' ')













    pass

if __name__ == '__main__':

    main()

import sys

sys.setrecursionlimit(2**31 - 1)
input = sys.stdin.readline
write = lambda x: sys.stdout.write(str(x))
LMIIS = lambda: list(map(int, input().split()))
II = lambda: int(input())
dbg = lambda *something: print(*something) if DEBUG is True else 0
DEBUG = False


def main():
    N = II()
    t = [-1] * N
    E = [[] for _ in range(N)]
    reached = [False] * N
    for _ in range(N - 1):
        u, v, w = LMIIS()
        u -= 1
        v -= 1
        E[u].append((v, w))
        E[v].append((u, w))
    dbg(E)
    t[E[0][0][0]] = 0

    def search(u):
        for v, w in E[u]:
            if t[v] == -1:
                t[v] = t[u] if w % 2 == 0 else t[u] ^ 1
                search(v)

    search(E[0][0][0])
    for i in t:
        write(i)
        write(" ")
    pass


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(2**31 - 1)
input = sys.stdin.readline
write = lambda x: sys.stdout.write(str(x))
LMIIS = lambda: list(map(int, input().split()))
II = lambda: int(input())
dbg = lambda *something: print(*something) if DEBUG is True else 0
DEBUG = False


def main():
    N = II()
    t = [-1] * N
    E = [[] for _ in range(N)]
    reached = [False] * N
    for _ in range(N - 1):
        u, v, w = LMIIS()
        u -= 1
        v -= 1
        E[u].append((v, w))
        E[v].append((u, w))
    dbg(E)
    t[E[0][0][0]] = 0
    # def search(u):
    #     for v,w in E[u]:
    #         if t[v] == -1:
    #             t[v] = t[u] if w % 2 == 0 else t[u]^1
    #             search(v)
    # search(E[0][0][0])
    reached = [False] * N
    q = [E[0][0][0]]
    while q:
        u = q.pop()
        reached[u] = True
        for v, w in E[u]:
            if reached[v] != True and t[v] == -1:
                t[v] = t[u] if w % 2 == 0 else t[u] ^ 1
                q.append(v)
    for i in t:
        write(i)
        write(" ")
    pass


if __name__ == "__main__":
    main()

- -    def search(u): +    # def search(u): +    #     for v,w in E[u]: +    #         if t[v] == -1: +    #             t[v] = t[u] if w % 2 == 0 else t[u]^1 +    #             search(v) +    # search(E[0][0][0]) +    reached = [False] * N +    q = [E[0][0][0]] +    while q: +        u = q.pop() +        reached[u] = True -            if t[v] == -1: +            if reached[v] != True and t[v] == -1: -                search(v) - -    search(E[0][0][0]) +                q.append(v)