import sys

readline = sys.stdin.readline

readlines = sys.stdin.readlines

read = sys.stdin.read





N = int(readline())

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



for i in readlines():

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

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

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



stack = [1]

parent = [0] * (N + 1)

color = [0] * (N + 1)



while stack:

    here = stack.pop()

    for x, w in graph[here]:

        if x == parent[here]:

            continue

        parent[x] = here

        color[x] = color[here] ^ (w % 2)

        stack.append(x)



for i in color[1:]:

    print(i)
import sys

readline = sys.stdin.readline

readlines = sys.stdin.readlines

read = sys.stdin.read



def main():

    N = int(readline())

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



    for i in readlines():

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

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

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



    stack = [1]

    parent = [0] * (N + 1)

    color = [0] * (N + 1)



    while stack:

        here = stack.pop()

        for x, w in graph[here]:

            if x == parent[here]:

                continue

            parent[x] = here

            color[x] = color[here] ^ (w % 2)

            stack.append(x)



    for i in color[1:]:

        print(i)





if __name__ == '__main__':

    main()
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
read = sys.stdin.read
N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in readlines():
    u, v, w = list(map(int, i.split()))
    graph[u].append((v, w))
    graph[v].append((u, w))
stack = [1]
parent = [0] * (N + 1)
color = [0] * (N + 1)
while stack:
    here = stack.pop()
    for x, w in graph[here]:
        if x == parent[here]:
            continue
        parent[x] = here
        color[x] = color[here] ^ (w % 2)
        stack.append(x)
for i in color[1:]:
    print(i)

import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
read = sys.stdin.read


def main():
    N = int(readline())
    graph = [[] for _ in range(N + 1)]
    for i in readlines():
        u, v, w = list(map(int, i.split()))
        graph[u].append((v, w))
        graph[v].append((u, w))
    stack = [1]
    parent = [0] * (N + 1)
    color = [0] * (N + 1)
    while stack:
        here = stack.pop()
        for x, w in graph[here]:
            if x == parent[here]:
                continue
            parent[x] = here
            color[x] = color[here] ^ (w % 2)
            stack.append(x)
    for i in color[1:]:
        print(i)


if __name__ == "__main__":
    main()

-N = int(readline()) -graph = [[] for _ in range(N + 1)] -for i in readlines(): -    u, v, w = list(map(int, i.split())) -    graph[u].append((v, w)) -    graph[v].append((u, w)) -stack = [1] -parent = [0] * (N + 1) -color = [0] * (N + 1) -while stack: -    here = stack.pop() -    for x, w in graph[here]: -        if x == parent[here]: -            continue -        parent[x] = here -        color[x] = color[here] ^ (w % 2) -        stack.append(x) -for i in color[1:]: -    print(i) + + +def main(): +    N = int(readline()) +    graph = [[] for _ in range(N + 1)] +    for i in readlines(): +        u, v, w = list(map(int, i.split())) +        graph[u].append((v, w)) +        graph[v].append((u, w)) +    stack = [1] +    parent = [0] * (N + 1) +    color = [0] * (N + 1) +    while stack: +        here = stack.pop() +        for x, w in graph[here]: +            if x == parent[here]: +                continue +            parent[x] = here +            color[x] = color[here] ^ (w % 2) +            stack.append(x) +    for i in color[1:]: +        print(i) + + +if __name__ == "__main__": +    main()