# ABC126D - Even Relation

import sys



sys.setrecursionlimit(10 ** 9)





def dfs(v: int, p: int) -> None:

    for u, w in T[v]:

        if u != p:

            D[u] = D[v] + w

            dfs(u, v)





def main():

    global T, D

    N, *A = map(int, open(0).read().split())

    T = [[] for _ in range(N + 1)]

    for i in range(0, (N - 1) * 3, 3):

        v, u, w = A[i : i + 3]

        T[v] += [(u, w)]

        T[u] += [(v, w)]

    D = [0] * (N + 1)  # D[i] := distance from vertex 1 (root)

    dfs(1, -1)

    ans = [i % 2 for i in D[1:]]  # same parity of distance -> same group

    print(*ans, sep="\n")





if __name__ == "__main__":

    main()

# ABC126D - Even Relation

import sys



sys.setrecursionlimit(10 ** 9)





def dfs(v: int, p: int) -> None:

    for u, w in T[v]:

        if u != p:

            D[u] = (D[v] + w) % 2

            dfs(u, v)





def main():

    global T, D

    N, *A = map(int, open(0).read().split())

    T = [[] for _ in range(N + 1)]

    for i in range(0, (N - 1) * 3, 3):

        v, u, w = A[i : i + 3]

        T[v] += [(u, w)]

        T[u] += [(v, w)]

    D = [0] * (N + 1)  # D[i] := distance from vertex 1 (root)

    dfs(1, -1)

    print(*D[1:], sep="\n")





if __name__ == "__main__":

    main()

# ABC126D - Even Relation
import sys

sys.setrecursionlimit(10**9)


def dfs(v: int, p: int) -> None:
    for u, w in T[v]:
        if u != p:
            D[u] = D[v] + w
            dfs(u, v)


def main():
    global T, D
    N, *A = map(int, open(0).read().split())
    T = [[] for _ in range(N + 1)]
    for i in range(0, (N - 1) * 3, 3):
        v, u, w = A[i : i + 3]
        T[v] += [(u, w)]
        T[u] += [(v, w)]
    D = [0] * (N + 1)  # D[i] := distance from vertex 1 (root)
    dfs(1, -1)
    ans = [i % 2 for i in D[1:]]  # same parity of distance -> same group
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

# ABC126D - Even Relation
import sys

sys.setrecursionlimit(10**9)


def dfs(v: int, p: int) -> None:
    for u, w in T[v]:
        if u != p:
            D[u] = (D[v] + w) % 2
            dfs(u, v)


def main():
    global T, D
    N, *A = map(int, open(0).read().split())
    T = [[] for _ in range(N + 1)]
    for i in range(0, (N - 1) * 3, 3):
        v, u, w = A[i : i + 3]
        T[v] += [(u, w)]
        T[u] += [(v, w)]
    D = [0] * (N + 1)  # D[i] := distance from vertex 1 (root)
    dfs(1, -1)
    print(*D[1:], sep="\n")


if __name__ == "__main__":
    main()

-            D[u] = D[v] + w +            D[u] = (D[v] + w) % 2 -    ans = [i % 2 for i in D[1:]]  # same parity of distance -> same group -    print(*ans, sep="\n") +    print(*D[1:], sep="\n")