import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**5)





N = int(eval(input()))

G = [[] for _ in range(N)]

for _ in range(N-1):

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

    G[u-1].append([v-1, w])

    G[v-1].append([u-1, w])

ans = [0]*N





def dfs(v, p, c):

    global ans

    ans[v] = c

    for e in G[v]:

        nv, cost = e

        if nv == p:

            continue

        if (cost % 2) == 0:

            dfs(nv, v, c)

        else:

            dfs(nv, v, (c+1) % 2)





def main():

    dfs(0, -1, 0)

    for c in ans:

        print(c)





if __name__ == '__main__':

    main()

import sys

sys.setrecursionlimit(10**5)

input = sys.stdin.readline





N = int(eval(input()))

G = [[] for _ in range(N)]

for _ in range(N-1):

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

    G[u-1].append([v-1, w])

    G[v-1].append([u-1, w])

ans = [0]*N





def dfs(v, p, c):

    global ans

    ans[v] = c

    for e in G[v]:

        nv, cost = e

        if nv == p:

            continue

        if (cost % 2) == 0:

            dfs(nv, v, c)

        else:

            dfs(nv, v, (c+1) % 2)





def main():

    dfs(0, -1, 0)

    for c in ans:

        print(c)





if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**5)
N = int(eval(input()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w])
ans = [0] * N


def dfs(v, p, c):
    global ans
    ans[v] = c
    for e in G[v]:
        nv, cost = e
        if nv == p:
            continue
        if (cost % 2) == 0:
            dfs(nv, v, c)
        else:
            dfs(nv, v, (c + 1) % 2)


def main():
    dfs(0, -1, 0)
    for c in ans:
        print(c)


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(10**5)
input = sys.stdin.readline
N = int(eval(input()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w])
ans = [0] * N


def dfs(v, p, c):
    global ans
    ans[v] = c
    for e in G[v]:
        nv, cost = e
        if nv == p:
            continue
        if (cost % 2) == 0:
            dfs(nv, v, c)
        else:
            dfs(nv, v, (c + 1) % 2)


def main():
    dfs(0, -1, 0)
    for c in ans:
        print(c)


if __name__ == "__main__":
    main()

+sys.setrecursionlimit(10**5) -sys.setrecursionlimit(10**5)