def d_even_relation_dfs(N, Nodes):  # DFSによる

    import sys

    sys.setrecursionlimit(10**6)

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

    for u, v, w in Nodes:  # 0-basedとする

        graph[u - 1].append((v - 1, w))

        graph[v - 1].append((u - 1, w))



    def distance_from_root(parent, current, distance, ret=[0] * N):  # 根(頂点0)から各頂点への距離

        def dfs(p, c, d):

            ret[c] = d

            for next_edge, dist in graph[c]:

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

                    dfs(c, next_edge, d + dist)

        dfs(parent, current, distance)

        return ret

    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root(-1, 0, 0))  # 根の親は-1番とする

    return ' '.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_dfs(N, Nodes)))
def d_even_relation_bfs():

    from collections import deque

    N = int(eval(input()))

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



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

    for u, v, w in Edges:  # 頂点は 0-indexed とする

        graph[u - 1].append((v - 1, w))

        graph[v - 1].append((u - 1, w))

    distance_from_root = [0] * N  # 根は頂点 0 とする



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

    while queue:

        parent, current, distance = queue.pop()

        distance_from_root[current] = distance

        for next_vertex, dist in graph[current]:

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

                queue.appendleft((current, next_vertex, distance + dist))

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

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



print((d_even_relation_bfs()))
def d_even_relation_dfs(N, Nodes):  # DFSによる
    import sys

    sys.setrecursionlimit(10**6)
    graph = [[] for _ in range(N)]
    for u, v, w in Nodes:  # 0-basedとする
        graph[u - 1].append((v - 1, w))
        graph[v - 1].append((u - 1, w))

    def distance_from_root(parent, current, distance, ret=[0] * N):  # 根(頂点0)から各頂点への距離
        def dfs(p, c, d):
            ret[c] = d
            for next_edge, dist in graph[c]:
                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる
                    dfs(c, next_edge, d + dist)

        dfs(parent, current, distance)
        return ret

    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root(-1, 0, 0))  # 根の親は-1番とする
    return " ".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_dfs(N, Nodes)))

def d_even_relation_bfs():
    from collections import deque

    N = int(eval(input()))
    Edges = [[int(i) for i in input().split()] for j in range(N - 1)]
    graph = [[] for _ in range(N)]
    for u, v, w in Edges:  # 頂点は 0-indexed とする
        graph[u - 1].append((v - 1, w))
        graph[v - 1].append((u - 1, w))
    distance_from_root = [0] * N  # 根は頂点 0 とする
    queue = deque([(-1, 0, 0)])  # 親と現在の頂点番号，根から親までの距離
    while queue:
        parent, current, distance = queue.pop()
        distance_from_root[current] = distance
        for next_vertex, dist in graph[current]:
            if parent != next_vertex:  # 木を「逆戻り」しない頂点だけ調べる
                queue.appendleft((current, next_vertex, distance + dist))
    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root)
    return " ".join(map(str, ans))


print((d_even_relation_bfs()))

-def d_even_relation_dfs(N, Nodes):  # DFSによる -    import sys +def d_even_relation_bfs(): +    from collections import deque -    sys.setrecursionlimit(10**6) +    N = int(eval(input())) +    Edges = [[int(i) for i in input().split()] for j in range(N - 1)] -    for u, v, w in Nodes:  # 0-basedとする +    for u, v, w in Edges:  # 頂点は 0-indexed とする - -    def distance_from_root(parent, current, distance, ret=[0] * N):  # 根(頂点0)から各頂点への距離 -        def dfs(p, c, d): -            ret[c] = d -            for next_edge, dist in graph[c]: -                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる -                    dfs(c, next_edge, d + dist) - -        dfs(parent, current, distance) -        return ret - -    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root(-1, 0, 0))  # 根の親は-1番とする +    distance_from_root = [0] * N  # 根は頂点 0 とする +    queue = deque([(-1, 0, 0)])  # 親と現在の頂点番号，根から親までの距離 +    while queue: +        parent, current, distance = queue.pop() +        distance_from_root[current] = distance +        for next_vertex, dist in graph[current]: +            if parent != next_vertex:  # 木を「逆戻り」しない頂点だけ調べる +                queue.appendleft((current, next_vertex, distance + dist)) +    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root) -N = int(eval(input())) -Nodes = [[int(i) for i in input().split()] for j in range(N - 1)] -print((d_even_relation_dfs(N, Nodes))) +print((d_even_relation_bfs()))