import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


#隣接リスト 1-order
def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append([edge[1], edge[2]])
        res[edge[1]].append([edge[0], edge[2]])
    return res


def main():
    N = NI()
    edges = [NLI() for _ in range(N-1)]
    graph = make_adjlist_nond(N, edges)
    colors = [0]*(N+1)

    def dfs(node, prev):
        for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

    dfs(1, 0)
    print("\n".join(map(str, colors[1:])))


if __name__ == "__main__":
    main() import sys sys import math math from collections import deque sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip NI = lambda: int(input()) NI lambda: int(input()) int(input()) int input() input NMI = lambda: map(int, input().split()) NMI lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split NLI = lambda: list(NMI()) NLI lambda: list(NMI()) list(NMI()) list NMI() NMI SI = lambda: input() SI lambda: input() input() input def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append([edge[1], edge[2]])
        res[edge[1]].append([edge[0], edge[2]])
    return res make_adjlist_nond [] for _ in range(n + 1) for _ in range(n + 1) _ range(n + 1) range n + 1 n 1 for _ in range(n + 1) [] res = [[] for _ in range(n + 1)] res [[] for _ in range(n + 1)] for edge in edges:
        res[edge[0]].append([edge[1], edge[2]])
        res[edge[1]].append([edge[0], edge[2]])
     edge edges res[edge[0]].append([edge[1], edge[2]]) [edge[0]].append [edge[0]] res edge[0] edge 0 append [edge[1], edge[2]] edge[1] edge 1 edge[2] edge 2 res[edge[1]].append([edge[0], edge[2]]) [edge[1]].append [edge[1]] res edge[1] edge 1 append [edge[0], edge[2]] edge[0] edge 0 edge[2] edge 2 return res res n n edges edges def main():
    N = NI()
    edges = [NLI() for _ in range(N-1)]
    graph = make_adjlist_nond(N, edges)
    colors = [0]*(N+1)

    def dfs(node, prev):
        for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

    dfs(1, 0)
    print("\n".join(map(str, colors[1:]))) main N = NI() N NI() NI NLI() for _ in range(N-1) for _ in range(N-1) _ range(N-1) range N-1 N 1 for _ in range(N-1) NLI() NLI edges = [NLI() for _ in range(N-1)] edges [NLI() for _ in range(N-1)] graph = make_adjlist_nond(N, edges) graph make_adjlist_nond(N, edges) make_adjlist_nond N edges colors = [0]*(N+1) colors [0]*(N+1) [0] 0 N+1 N 1 def dfs(node, prev):
        for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

     dfs for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

     goto dist graph[node] graph node if goto == prev:
                continue
             goto == prev goto prev continue colors[goto] = 1 - colors[node] if dist % 2 else colors[node] colors[goto] colors goto 1 - colors[node] if dist % 2 else colors[node] dist % 2 dist 2 1 - colors[node] 1 colors[node] colors node colors[node] colors node dfs(goto, node) dfs goto node node node prev prev dfs(1, 0) dfs 1 0 print("\n".join(map(str, colors[1:]))) print "\n".join(map(str, colors[1:])) "\n".join "\n" join map(str, colors[1:]) map str colors[1:] colors 1: 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = NI()
    edges = [NLI() for _ in range(N-1)]
    graph = make_adjlist_nond(N, edges)
    colors = [0]*(N+1)

    def dfs(node, prev):
        for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

    dfs(1, 0)
    print("\n".join(map(str, colors[1:]))) def main():
    N = NI()
    edges = [NLI() for _ in range(N-1)]
    graph = make_adjlist_nond(N, edges)
    colors = [0]*(N+1)

    def dfs(node, prev):
        for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

    dfs(1, 0)
    print("\n".join(map(str, colors[1:]))) main NMI = lambda: map(int, input().split()) lambda: map(int, input().split()) NMI SI = lambda: input() lambda: input() SI input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input NLI = lambda: list(NMI()) lambda: list(NMI()) NLI MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD NI = lambda: int(input()) lambda: int(input()) NI def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append([edge[1], edge[2]])
        res[edge[1]].append([edge[0], edge[2]])
    return res def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append([edge[1], edge[2]])
        res[edge[1]].append([edge[0], edge[2]])
    return res make_adjlist_nond
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


#隣接リスト 1-order
def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append([edge[1], edge[2]])
        res[edge[1]].append([edge[0], edge[2]])
    return res


def main():
    N = NI()
    edges = [NLI() for _ in range(N-1)]
    graph = make_adjlist_nond(N, edges)
    colors = [0]*(N+1)

    def dfs(node, prev):
        for goto, dist in graph[node]:
            if goto == prev:
                continue
            colors[goto] = 1 - colors[node] if dist % 2 else colors[node]
            dfs(goto, node)

    dfs(1, 0)
    print("\n".join(map(str, colors[1:])))


if __name__ == "__main__":
    main()