import sys

sys.setrecursionlimit(4100000)



def Dfs(G, v, cur=0):

    color[v] = cur % 2

    for next_v in G[v]:

        if color[next_v[0]] != -1:

            continue

        Dfs(G, next_v[0], cur+next_v[1])





n = int(eval(input()))

e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n-1)]

g = [[] for i in range(n+1)]



for i in range(1, n):

    g[e[i][0]].append([e[i][1], e[i][2]])

    g[e[i][1]].append([e[i][0], e[i][2]])



color = [-1 for i in range(n+1)]

for v in range(1, n+1):

    if color[v] != -1:

        continue

    Dfs(g, v)



for i in range(1, n+1):

    print((color[i]))

import sys

sys.setrecursionlimit(4100000)

input = sys.stdin.readline

def main():

    def Dfs(G, v, cur=0):

        color[v] = cur % 2

        for next_v in G[v]:

            if color[next_v[0]] != -1:

                continue

            Dfs(G, next_v[0], cur+next_v[1])





    n = int(eval(input()))

    e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n-1)]

    g = [[] for i in range(n+1)]



    for i in range(1, n):

        g[e[i][0]].append([e[i][1], e[i][2]])

        g[e[i][1]].append([e[i][0], e[i][2]])



    color = [-1 for i in range(n+1)]

    for v in range(1, n+1):

        if color[v] != -1:

            continue

        Dfs(g, v)



    for i in range(1, n+1):

        print((color[i]))



if __name__ == '__main__':

    main()
import sys

sys.setrecursionlimit(4100000)


def Dfs(G, v, cur=0):
    color[v] = cur % 2
    for next_v in G[v]:
        if color[next_v[0]] != -1:
            continue
        Dfs(G, next_v[0], cur + next_v[1])


n = int(eval(input()))
e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n - 1)]
g = [[] for i in range(n + 1)]
for i in range(1, n):
    g[e[i][0]].append([e[i][1], e[i][2]])
    g[e[i][1]].append([e[i][0], e[i][2]])
color = [-1 for i in range(n + 1)]
for v in range(1, n + 1):
    if color[v] != -1:
        continue
    Dfs(g, v)
for i in range(1, n + 1):
    print((color[i]))

import sys

sys.setrecursionlimit(4100000)
input = sys.stdin.readline


def main():
    def Dfs(G, v, cur=0):
        color[v] = cur % 2
        for next_v in G[v]:
            if color[next_v[0]] != -1:
                continue
            Dfs(G, next_v[0], cur + next_v[1])

    n = int(eval(input()))
    e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n - 1)]
    g = [[] for i in range(n + 1)]
    for i in range(1, n):
        g[e[i][0]].append([e[i][1], e[i][2]])
        g[e[i][1]].append([e[i][0], e[i][2]])
    color = [-1 for i in range(n + 1)]
    for v in range(1, n + 1):
        if color[v] != -1:
            continue
        Dfs(g, v)
    for i in range(1, n + 1):
        print((color[i]))


if __name__ == "__main__":
    main()

+input = sys.stdin.readline -def Dfs(G, v, cur=0): -    color[v] = cur % 2 -    for next_v in G[v]: -        if color[next_v[0]] != -1: +def main(): +    def Dfs(G, v, cur=0): +        color[v] = cur % 2 +        for next_v in G[v]: +            if color[next_v[0]] != -1: +                continue +            Dfs(G, next_v[0], cur + next_v[1]) + +    n = int(eval(input())) +    e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n - 1)] +    g = [[] for i in range(n + 1)] +    for i in range(1, n): +        g[e[i][0]].append([e[i][1], e[i][2]]) +        g[e[i][1]].append([e[i][0], e[i][2]]) +    color = [-1 for i in range(n + 1)] +    for v in range(1, n + 1): +        if color[v] != -1: -        Dfs(G, next_v[0], cur + next_v[1]) +        Dfs(g, v) +    for i in range(1, n + 1): +        print((color[i])) -n = int(eval(input())) -e = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n - 1)] -g = [[] for i in range(n + 1)] -for i in range(1, n): -    g[e[i][0]].append([e[i][1], e[i][2]]) -    g[e[i][1]].append([e[i][0], e[i][2]]) -color = [-1 for i in range(n + 1)] -for v in range(1, n + 1): -    if color[v] != -1: -        continue -    Dfs(g, v) -for i in range(1, n + 1): -    print((color[i])) +if __name__ == "__main__": +    main()