# -*- coding: utf-8 -*-





def main():

    from collections import deque



    n = int(eval(input()))

    to = [[] for _ in range(n)]

    cost = [[] for _ in range(n)]



    for i in range(n - 1):

        ui, vi, wi = list(map(int, input().split()))

        ui -= 1

        vi -= 1

        to[ui].append(vi)

        to[vi].append(ui)

        cost[ui].append(wi)

        cost[vi].append(wi)



    ans = [-1 for _ in range(n)]

    q = deque()

    ans[0] = 0

    q.append(0)



    while q:

        vj = q.popleft()



        for j in range(len(to[vj])):

            uj = to[vj][j]

            wj = cost[vj][j]



            if ans[uj] != -1:

                continue



            ans[uj] = (ans[vj] + wj) % 2

            q.append(uj)



    for a in ans:

        print(a)





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-





def main():

    from collections import deque



    n = int(eval(input()))

    graph = [[] for _ in range(n)]



    # See:

    # https://www.youtube.com/watch?v=26AWkQNRb-A

    # https://atcoder.jp/contests/abc126/submissions/5456359

    for i in range(n - 1):

        ui, vi, wi = list(map(int, input().split()))

        ui -= 1

        vi -= 1

        graph[ui].append((vi, wi))

        graph[vi].append((ui, wi))



    ans = [-1 for _ in range(n)]

    q = deque()

    ans[0] = 0

    q.append(0)



    while q:

        vj = q.popleft()



        for uj, wj in graph[vj]:

            if ans[uj] != -1:

                continue



            ans[uj] = (ans[vj] + wj) % 2

            q.append(uj)



    print(('\n'.join(map(str, ans))))





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-
def main():
    from collections import deque

    n = int(eval(input()))
    to = [[] for _ in range(n)]
    cost = [[] for _ in range(n)]
    for i in range(n - 1):
        ui, vi, wi = list(map(int, input().split()))
        ui -= 1
        vi -= 1
        to[ui].append(vi)
        to[vi].append(ui)
        cost[ui].append(wi)
        cost[vi].append(wi)
    ans = [-1 for _ in range(n)]
    q = deque()
    ans[0] = 0
    q.append(0)
    while q:
        vj = q.popleft()
        for j in range(len(to[vj])):
            uj = to[vj][j]
            wj = cost[vj][j]
            if ans[uj] != -1:
                continue
            ans[uj] = (ans[vj] + wj) % 2
            q.append(uj)
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-
def main():
    from collections import deque

    n = int(eval(input()))
    graph = [[] for _ in range(n)]
    # See:
    # https://www.youtube.com/watch?v=26AWkQNRb-A
    # https://atcoder.jp/contests/abc126/submissions/5456359
    for i in range(n - 1):
        ui, vi, wi = list(map(int, input().split()))
        ui -= 1
        vi -= 1
        graph[ui].append((vi, wi))
        graph[vi].append((ui, wi))
    ans = [-1 for _ in range(n)]
    q = deque()
    ans[0] = 0
    q.append(0)
    while q:
        vj = q.popleft()
        for uj, wj in graph[vj]:
            if ans[uj] != -1:
                continue
            ans[uj] = (ans[vj] + wj) % 2
            q.append(uj)
    print(("\n".join(map(str, ans))))


if __name__ == "__main__":
    main()

-    to = [[] for _ in range(n)] -    cost = [[] for _ in range(n)] +    graph = [[] for _ in range(n)] +    # See: +    # https://www.youtube.com/watch?v=26AWkQNRb-A +    # https://atcoder.jp/contests/abc126/submissions/5456359 -        to[ui].append(vi) -        to[vi].append(ui) -        cost[ui].append(wi) -        cost[vi].append(wi) +        graph[ui].append((vi, wi)) +        graph[vi].append((ui, wi)) -        for j in range(len(to[vj])): -            uj = to[vj][j] -            wj = cost[vj][j] +        for uj, wj in graph[vj]: -    for a in ans: -        print(a) +    print(("\n".join(map(str, ans))))