from collections import defaultdict

import sys



def tree_path_dict():

    sys.setrecursionlimit(100000)

    n = int(eval(input()))

    edge = defaultdict(lambda: defaultdict(lambda: float("inf")))



    for _ in range(n - 1):

        u, v, w = list(map(int, input().split()))

        edge[u][v] = w

        edge[v][u] = w



    d = [-1] * (n + 1)



    def walk(i, c):

        if d[i] == -1:

            d[i] = c

            for node, dist in list(edge[i].items()):

                walk(node, c + dist)



    walk(1, 0)

    for i in d[1:]:

        print((i % 2))



        

tree_path_dict()
import sys

def tree_path():

    # 辺と長さが与えられる

    # 頂点1からの各点の距離を計算する

    # 距離が偶数か奇数かで色分け

    def walk(i, c):

        if d[i] == -1:

            d[i] = c

            for node, dist in path[i]:

                walk(node, c + dist)



    sys.setrecursionlimit(100000)

    n = int(eval(input()))

    path = [[] for _ in range(n + 1)]

    for _ in range(n - 1):

        u, v, w = list(map(int, input().split()))

        # 無向グラフ

        path[u].append([v, w])

        path[v].append([u, w])

    # d[0]は使わない

    d = [-1] * (n + 1)

    walk(1, 0)

    for item in d[1:]:

        print((item % 2))





tree_path()
from collections import defaultdict
import sys


def tree_path_dict():
    sys.setrecursionlimit(100000)
    n = int(eval(input()))
    edge = defaultdict(lambda: defaultdict(lambda: float("inf")))
    for _ in range(n - 1):
        u, v, w = list(map(int, input().split()))
        edge[u][v] = w
        edge[v][u] = w
    d = [-1] * (n + 1)

    def walk(i, c):
        if d[i] == -1:
            d[i] = c
            for node, dist in list(edge[i].items()):
                walk(node, c + dist)

    walk(1, 0)
    for i in d[1:]:
        print((i % 2))


tree_path_dict()

import sys


def tree_path():
    # 辺と長さが与えられる
    # 頂点1からの各点の距離を計算する
    # 距離が偶数か奇数かで色分け
    def walk(i, c):
        if d[i] == -1:
            d[i] = c
            for node, dist in path[i]:
                walk(node, c + dist)

    sys.setrecursionlimit(100000)
    n = int(eval(input()))
    path = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = list(map(int, input().split()))
        # 無向グラフ
        path[u].append([v, w])
        path[v].append([u, w])
    # d[0]は使わない
    d = [-1] * (n + 1)
    walk(1, 0)
    for item in d[1:]:
        print((item % 2))


tree_path()

-from collections import defaultdict -def tree_path_dict(): -    sys.setrecursionlimit(100000) -    n = int(eval(input())) -    edge = defaultdict(lambda: defaultdict(lambda: float("inf"))) -    for _ in range(n - 1): -        u, v, w = list(map(int, input().split())) -        edge[u][v] = w -        edge[v][u] = w -    d = [-1] * (n + 1) - +def tree_path(): +    # 辺と長さが与えられる +    # 頂点1からの各点の距離を計算する +    # 距離が偶数か奇数かで色分け -            for node, dist in list(edge[i].items()): +            for node, dist in path[i]: +    sys.setrecursionlimit(100000) +    n = int(eval(input())) +    path = [[] for _ in range(n + 1)] +    for _ in range(n - 1): +        u, v, w = list(map(int, input().split())) +        # 無向グラフ +        path[u].append([v, w]) +        path[v].append([u, w]) +    # d[0]は使わない +    d = [-1] * (n + 1) -    for i in d[1:]: -        print((i % 2)) +    for item in d[1:]: +        print((item % 2)) -tree_path_dict() +tree_path()