def d_even_relation_dfs():
    import sys
    sys.setrecursionlimit(10**6)
    N = int(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))

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

        ret[current] = distance
        for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
        return ret
    ans = (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0))  # 根の親は -1 番
    return ' '.join(map(str, ans))

print(d_even_relation_dfs()) def d_even_relation_dfs():
    import sys
    sys.setrecursionlimit(10**6)
    N = int(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))

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

        ret[current] = distance
        for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
        return ret
    ans = (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0))  # 根の親は -1 番
    return ' '.join(map(str, ans)) d_even_relation_dfs import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 N = int(input()) N int(input()) int input() input [int(i) for i in input().split()] for j in range(N - 1) for j in range(N - 1) j range(N - 1) range N - 1 N 1 for j in range(N - 1) [int(i) for i in input().split()] Edges = [[int(i) for i in input().split()] for j in range(N - 1)] Edges [[int(i) for i in input().split()] for j in range(N - 1)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] graph = [[] for _ in range(N)] 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))

     u v w Edges graph[u - 1].append((v - 1, w)) [u - 1].append [u - 1] graph u - 1 u 1 append (v - 1, w) v - 1 v 1 w graph[v - 1].append((u - 1, w)) [v - 1].append [v - 1] graph v - 1 v 1 append (u - 1, w) u - 1 u 1 w def distance_from_root(parent, current, distance, ret=None):
        """根 (頂点 0) から各頂点への距離"""
        if ret is None:
            ret = [0] * N

        ret[current] = distance
        for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
        return ret
     distance_from_root """根 (頂点 0) から各頂点への距離""" if ret is None:
            ret = [0] * N

         ret is None ret None ret = [0] * N ret [0] * N [0] 0 N ret[current] = distance ret[current] ret current distance for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
         next_vertex dist graph[current] graph current if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
         next_vertex != parent next_vertex parent distance_from_root(current, next_vertex, distance + dist, ret) distance_from_root current next_vertex distance + dist distance dist ret return ret ret parent parent current current distance distance ret=None ret None 0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0) for d in distance_from_root(-1, 0, 0) d distance_from_root(-1, 0, 0) distance_from_root -1 0 0 for d in distance_from_root(-1, 0, 0) 0 if d % 2 else 1 d % 2 d 2 0 1 ans = (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0)) ans (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0)) return ' '.join(map(str, ans)) ' '.join(map(str, ans)) ' '.join ' ' join map(str, ans) map str ans print(d_even_relation_dfs()) print d_even_relation_dfs() d_even_relation_dfs def d_even_relation_dfs():
    import sys
    sys.setrecursionlimit(10**6)
    N = int(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))

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

        ret[current] = distance
        for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
        return ret
    ans = (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0))  # 根の親は -1 番
    return ' '.join(map(str, ans)) def d_even_relation_dfs():
    import sys
    sys.setrecursionlimit(10**6)
    N = int(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))

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

        ret[current] = distance
        for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
        return ret
    ans = (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0))  # 根の親は -1 番
    return ' '.join(map(str, ans)) d_even_relation_dfs
def d_even_relation_dfs():
    import sys
    sys.setrecursionlimit(10**6)
    N = int(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))

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

        ret[current] = distance
        for next_vertex, dist in graph[current]:
            if next_vertex != parent:
                distance_from_root(current, next_vertex, distance + dist, ret)
        return ret
    ans = (0 if d % 2 else 1 for d in distance_from_root(-1, 0, 0))  # 根の親は -1 番
    return ' '.join(map(str, ans))

print(d_even_relation_dfs())