import sys

from collections import deque



def solve(tree, u, v):



    colors = {}

    colors[u] = 0

    stack = deque([u])

    while stack:

        u = stack.pop()

        for v in tree[u]:

            if v in colors:

                continue



            stack.append(v)

            if tree[u][v] % 2 == 0:

                colors[v] = colors[u]

            else:

                colors[v] = 0 if colors[u] == 1 else 1



    sorted(colors)

    for c in colors:

        print(colors[c])



if __name__ == '__main__':



    tree = {}

    n = sys.stdin.readline().strip()

    for _ in range(int(n)-1):

        u, v ,w = list(map(int, sys.stdin.readline().strip().split(" ")))

        if u not in tree:

            tree[u] = {}

        if v not in tree:

            tree[v] = {}

        tree[u][v] = w

        tree[v][u] = w



    solve(tree, u, v)
import sys

from collections import deque

input = sys.stdin.readline

N = int(eval(input()))



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

for _ in range(N-1):

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

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

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



q = deque()

q.append((0, 0))

color = {}

while q:

    node, dist = q.popleft()

    if node in color:

        continue

    if dist % 2 == 0:

        color[node] = 0

    else:

        color[node] = 1

    for n_node, n_dist in edges[node]:

        q.append((n_node, dist+n_dist))



for i in range(N):

    print((color[i]))
import sys
from collections import deque


def solve(tree, u, v):
    colors = {}
    colors[u] = 0
    stack = deque([u])
    while stack:
        u = stack.pop()
        for v in tree[u]:
            if v in colors:
                continue
            stack.append(v)
            if tree[u][v] % 2 == 0:
                colors[v] = colors[u]
            else:
                colors[v] = 0 if colors[u] == 1 else 1
    sorted(colors)
    for c in colors:
        print(colors[c])


if __name__ == "__main__":
    tree = {}
    n = sys.stdin.readline().strip()
    for _ in range(int(n) - 1):
        u, v, w = list(map(int, sys.stdin.readline().strip().split(" ")))
        if u not in tree:
            tree[u] = {}
        if v not in tree:
            tree[v] = {}
        tree[u][v] = w
        tree[v][u] = w
    solve(tree, u, v)

import sys
from collections import deque

input = sys.stdin.readline
N = int(eval(input()))
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    edges[u - 1].append((v - 1, w))
    edges[v - 1].append((u - 1, w))
q = deque()
q.append((0, 0))
color = {}
while q:
    node, dist = q.popleft()
    if node in color:
        continue
    if dist % 2 == 0:
        color[node] = 0
    else:
        color[node] = 1
    for n_node, n_dist in edges[node]:
        q.append((n_node, dist + n_dist))
for i in range(N):
    print((color[i]))

- -def solve(tree, u, v): -    colors = {} -    colors[u] = 0 -    stack = deque([u]) -    while stack: -        u = stack.pop() -        for v in tree[u]: -            if v in colors: -                continue -            stack.append(v) -            if tree[u][v] % 2 == 0: -                colors[v] = colors[u] -            else: -                colors[v] = 0 if colors[u] == 1 else 1 -    sorted(colors) -    for c in colors: -        print(colors[c]) - - -if __name__ == "__main__": -    tree = {} -    n = sys.stdin.readline().strip() -    for _ in range(int(n) - 1): -        u, v, w = list(map(int, sys.stdin.readline().strip().split(" "))) -        if u not in tree: -            tree[u] = {} -        if v not in tree: -            tree[v] = {} -        tree[u][v] = w -        tree[v][u] = w -    solve(tree, u, v) +input = sys.stdin.readline +N = int(eval(input())) +edges = [[] for _ in range(N)] +for _ in range(N - 1): +    u, v, w = list(map(int, input().split())) +    edges[u - 1].append((v - 1, w)) +    edges[v - 1].append((u - 1, w)) +q = deque() +q.append((0, 0)) +color = {} +while q: +    node, dist = q.popleft() +    if node in color: +        continue +    if dist % 2 == 0: +        color[node] = 0 +    else: +        color[node] = 1 +    for n_node, n_dist in edges[node]: +        q.append((n_node, dist + n_dist)) +for i in range(N): +    print((color[i]))