N = int(eval(input()))

from collections import deque



tree = [{} for _ in range(N)]



color = [-1]*N

for i in range(N-1):

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

    tree[u-1][v-1] = w

    tree[v-1][u-1] = w



queue = deque()

queue.append((0, 0))



while queue:

    v, w = queue.pop()

    color[v] = w%2

    for i in list(tree[v].keys()):

        if color[i]==-1:

            queue.append((i, w+tree[v][i]))



for c in color:

    print(c)
import sys

def input(): return sys.stdin.readline().strip()

def mapint(): return list(map(int, input().split()))

sys.setrecursionlimit(10**9)



N = int(eval(input()))

graph = [{} for _ in range(N)]



for _ in range(N-1):

    u, v, w = mapint()

    graph[u-1][v-1] = w%2

    graph[v-1][u-1] = w%2



from collections import deque

stack = deque([0])



colors = [-1]*N

colors[0] = 0

while stack:

    v = stack.pop()

    for nx in list(graph[v].keys()):

        if colors[nx]==-1:

            w = graph[v][nx]

            colors[nx] = (colors[v]+w)%2

            stack.append(nx)



for a in colors:

    print(a)
N = int(eval(input()))
from collections import deque

tree = [{} for _ in range(N)]
color = [-1] * N
for i in range(N - 1):
    u, v, w = list(map(int, input().split()))
    tree[u - 1][v - 1] = w
    tree[v - 1][u - 1] = w
queue = deque()
queue.append((0, 0))
while queue:
    v, w = queue.pop()
    color[v] = w % 2
    for i in list(tree[v].keys()):
        if color[i] == -1:
            queue.append((i, w + tree[v][i]))
for c in color:
    print(c)

import sys


def input():
    return sys.stdin.readline().strip()


def mapint():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)
N = int(eval(input()))
graph = [{} for _ in range(N)]
for _ in range(N - 1):
    u, v, w = mapint()
    graph[u - 1][v - 1] = w % 2
    graph[v - 1][u - 1] = w % 2
from collections import deque

stack = deque([0])
colors = [-1] * N
colors[0] = 0
while stack:
    v = stack.pop()
    for nx in list(graph[v].keys()):
        if colors[nx] == -1:
            w = graph[v][nx]
            colors[nx] = (colors[v] + w) % 2
            stack.append(nx)
for a in colors:
    print(a)

+import sys + + +def input(): +    return sys.stdin.readline().strip() + + +def mapint(): +    return list(map(int, input().split())) + + +sys.setrecursionlimit(10**9) +graph = [{} for _ in range(N)] +for _ in range(N - 1): +    u, v, w = mapint() +    graph[u - 1][v - 1] = w % 2 +    graph[v - 1][u - 1] = w % 2 -tree = [{} for _ in range(N)] -color = [-1] * N -for i in range(N - 1): -    u, v, w = list(map(int, input().split())) -    tree[u - 1][v - 1] = w -    tree[v - 1][u - 1] = w -queue = deque() -queue.append((0, 0)) -while queue: -    v, w = queue.pop() -    color[v] = w % 2 -    for i in list(tree[v].keys()): -        if color[i] == -1: -            queue.append((i, w + tree[v][i])) -for c in color: -    print(c) +stack = deque([0]) +colors = [-1] * N +colors[0] = 0 +while stack: +    v = stack.pop() +    for nx in list(graph[v].keys()): +        if colors[nx] == -1: +            w = graph[v][nx] +            colors[nx] = (colors[v] + w) % 2 +            stack.append(nx) +for a in colors: +    print(a)