import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import defaultdict, deque
    n = input_int()
    G = defaultdict(dict)
    color = [None] * (n + 1)
    for _ in range(n - 1):
        u, v, w = input_int_list()
        G[u][v] = w
        G[v][u] = w

    # ノード1 を起点にBFSをする
    color[1] = 0
    dq = deque()
    dq.append((1, 0))  # node,cost
    while dq:
        u, cur = dq.popleft()
        for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
    for c in color[1:]:
        print(c)

    return


if __name__ == "__main__":
    main() import sys sys def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip def input_int():
    return int(input()) input_int return int(input()) int(input()) int input() input def input_int_list():
    return [int(i) for i in input().split()] input_int_list int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i return [int(i) for i in input().split()] [int(i) for i in input().split()] def main():
    from collections import defaultdict, deque
    n = input_int()
    G = defaultdict(dict)
    color = [None] * (n + 1)
    for _ in range(n - 1):
        u, v, w = input_int_list()
        G[u][v] = w
        G[v][u] = w

    # ノード1 を起点にBFSをする
    color[1] = 0
    dq = deque()
    dq.append((1, 0))  # node,cost
    while dq:
        u, cur = dq.popleft()
        for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
    for c in color[1:]:
        print(c)

    return main from collections import defaultdict, deque n = input_int() n input_int() input_int G = defaultdict(dict) G defaultdict(dict) defaultdict dict color = [None] * (n + 1) color [None] * (n + 1) [None] None n + 1 n 1 for _ in range(n - 1):
        u, v, w = input_int_list()
        G[u][v] = w
        G[v][u] = w

    # ノード1 を起点にBFSをする
     _ range(n - 1) range n - 1 n 1 u, v, w = input_int_list() u input_int_list() input_int_list v w G[u][v] = w G[u][v] [u] G u v w G[v][u] = w G[v][u] [v] G v u w color[1] = 0 color[1] color 1 0 dq = deque() dq deque() deque dq.append((1, 0)) dq.append dq append (1, 0) 1 0 while dq:
        u, cur = dq.popleft()
        for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
     dq u, cur = dq.popleft() u dq.popleft() dq.popleft dq popleft cur for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
     v cost G[u].items() [u].items [u] G u items if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
     color[v] is None color[v] color v None if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                 (cur + cost) % 2 == 0 (cur + cost) % 2 cur + cost cur cost 2 0 color[v] = 0 color[v] color v 0 color[v] = 1 color[v] color v 1 dq.append((v, cur + cost)) dq.append dq append (v, cur + cost) v cur + cost cur cost for c in color[1:]:
        print(c)

     c color[1:] color 1: 1 print(c) print c return if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def input_int_list():
    return [int(i) for i in input().split()] def input_int_list():
    return [int(i) for i in input().split()] input_int_list def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input def main():
    from collections import defaultdict, deque
    n = input_int()
    G = defaultdict(dict)
    color = [None] * (n + 1)
    for _ in range(n - 1):
        u, v, w = input_int_list()
        G[u][v] = w
        G[v][u] = w

    # ノード1 を起点にBFSをする
    color[1] = 0
    dq = deque()
    dq.append((1, 0))  # node,cost
    while dq:
        u, cur = dq.popleft()
        for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
    for c in color[1:]:
        print(c)

    return def main():
    from collections import defaultdict, deque
    n = input_int()
    G = defaultdict(dict)
    color = [None] * (n + 1)
    for _ in range(n - 1):
        u, v, w = input_int_list()
        G[u][v] = w
        G[v][u] = w

    # ノード1 を起点にBFSをする
    color[1] = 0
    dq = deque()
    dq.append((1, 0))  # node,cost
    while dq:
        u, cur = dq.popleft()
        for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
    for c in color[1:]:
        print(c)

    return main def input_int():
    return int(input()) def input_int():
    return int(input()) input_int
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import defaultdict, deque
    n = input_int()
    G = defaultdict(dict)
    color = [None] * (n + 1)
    for _ in range(n - 1):
        u, v, w = input_int_list()
        G[u][v] = w
        G[v][u] = w

    # ノード1 を起点にBFSをする
    color[1] = 0
    dq = deque()
    dq.append((1, 0))  # node,cost
    while dq:
        u, cur = dq.popleft()
        for v, cost in G[u].items():
            if color[v] is None:
                if (cur + cost) % 2 == 0:
                    color[v] = 0
                else:
                    color[v] = 1
                dq.append((v, cur + cost))
    for c in color[1:]:
        print(c)

    return


if __name__ == "__main__":
    main()
