def d_even_relation(N, Nodes):

    from collections import deque

    graph = [{} for _ in range(N)]

    for u, v, w in Nodes:

        graph[u - 1][v - 1] = w

        graph[v - 1][u - 1] = w



    ans = [0] * N

    queue = deque([(-1, -1, 0)])

    while queue:

        previous, parent, child = queue.pop()

        if parent == -1:

            ans[child] = 0

        elif previous != child:

            length = graph[parent][child]

            if length % 2 == 0:

                ans[child] = ans[parent]

            else:

                ans[child] = 1 if ans[parent] == 0 else 0

        for k in list(graph[child].keys()):

            if parent != k:

                queue.appendleft((parent, child, k))

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



N = int(eval(input()))

Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]

print((d_even_relation(N, Nodes)))
def d_even_relation(N, Nodes):

    from collections import deque

    graph = [{} for _ in range(N)]

    for u, v, w in Nodes:

        graph[u - 1][v - 1] = w

        graph[v - 1][u - 1] = w



    distance_from_root = [0] * N  # 頂点1を根としたときの、各頂点への距離

    queue = deque([(-1, 0, 0)])  # 親の頂点番号、子の頂点番号、根から親までの距離

    while queue:

        parent, child, distance = queue.pop()

        if parent != -1:  # 今調べている頂点が根でない

            distance += (graph[parent][child] % 2)  # 偶奇だけわかればいい

            distance_from_root[child] = distance

        for k in list(graph[child].keys()):

            if parent != k:  # 木を「逆戻り」しない頂点だけ調べる

                queue.appendleft((child, k, distance))

    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root)

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



N = int(eval(input()))

Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]

print((d_even_relation(N, Nodes)))
def d_even_relation(N, Nodes):
    from collections import deque

    graph = [{} for _ in range(N)]
    for u, v, w in Nodes:
        graph[u - 1][v - 1] = w
        graph[v - 1][u - 1] = w
    ans = [0] * N
    queue = deque([(-1, -1, 0)])
    while queue:
        previous, parent, child = queue.pop()
        if parent == -1:
            ans[child] = 0
        elif previous != child:
            length = graph[parent][child]
            if length % 2 == 0:
                ans[child] = ans[parent]
            else:
                ans[child] = 1 if ans[parent] == 0 else 0
        for k in list(graph[child].keys()):
            if parent != k:
                queue.appendleft((parent, child, k))
    return "\n".join(map(str, ans))


N = int(eval(input()))
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
print((d_even_relation(N, Nodes)))

def d_even_relation(N, Nodes):
    from collections import deque

    graph = [{} for _ in range(N)]
    for u, v, w in Nodes:
        graph[u - 1][v - 1] = w
        graph[v - 1][u - 1] = w
    distance_from_root = [0] * N  # 頂点1を根としたときの、各頂点への距離
    queue = deque([(-1, 0, 0)])  # 親の頂点番号、子の頂点番号、根から親までの距離
    while queue:
        parent, child, distance = queue.pop()
        if parent != -1:  # 今調べている頂点が根でない
            distance += graph[parent][child] % 2  # 偶奇だけわかればいい
            distance_from_root[child] = distance
        for k in list(graph[child].keys()):
            if parent != k:  # 木を「逆戻り」しない頂点だけ調べる
                queue.appendleft((child, k, distance))
    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root)
    return "\n".join(map(str, ans))


N = int(eval(input()))
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
print((d_even_relation(N, Nodes)))

-    ans = [0] * N -    queue = deque([(-1, -1, 0)]) +    distance_from_root = [0] * N  # 頂点1を根としたときの、各頂点への距離 +    queue = deque([(-1, 0, 0)])  # 親の頂点番号、子の頂点番号、根から親までの距離 -        previous, parent, child = queue.pop() -        if parent == -1: -            ans[child] = 0 -        elif previous != child: -            length = graph[parent][child] -            if length % 2 == 0: -                ans[child] = ans[parent] -            else: -                ans[child] = 1 if ans[parent] == 0 else 0 +        parent, child, distance = queue.pop() +        if parent != -1:  # 今調べている頂点が根でない +            distance += graph[parent][child] % 2  # 偶奇だけわかればいい +            distance_from_root[child] = distance -            if parent != k: -                queue.appendleft((parent, child, k)) +            if parent != k:  # 木を「逆戻り」しない頂点だけ調べる +                queue.appendleft((child, k, distance)) +    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root)