import sys
sys.setrecursionlimit(10**6)

N = int(input())
paths = [dict() for i in range(N + 1)]
for i in range(N-1):
    u, v, w = map(int,input().split())
    paths[u][v] = w
    paths[v][u] = w

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in paths[now].items():
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1]) import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 N = int(input()) N int(input()) int input() input dict() for i in range(N + 1) for i in range(N + 1) i range(N + 1) range N + 1 N 1 for i in range(N + 1) dict() dict paths = [dict() for i in range(N + 1)] paths [dict() for i in range(N + 1)] for i in range(N-1):
    u, v, w = map(int,input().split())
    paths[u][v] = w
    paths[v][u] = w i range(N-1) range N-1 N 1 u, v, w = map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v w paths[u][v] = w paths[u][v] [u] paths u v w paths[v][u] = w paths[v][u] [v] paths v u w node_colors = [-1] * (N+1) node_colors [-1] * (N+1) [-1] -1 N+1 N 1 def route(last, now, dist):
    for next_node, next_distance in paths[now].items():
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance) route for next_node, next_distance in paths[now].items():
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance) next_node next_distance paths[now].items() [now].items [now] paths now items node_colors[next_node] = (dist + next_distance) % 2 node_colors[next_node] node_colors next_node (dist + next_distance) % 2 dist + next_distance dist next_distance 2 if next_node != last:
            route(now, next_node, dist + next_distance) next_node != last next_node last route(now, next_node, dist + next_distance) route now next_node dist + next_distance dist next_distance last last now now dist dist node_colors[1] = 0 node_colors[1] node_colors 1 0 route(0, 1, 0) route 0 1 0 for i in range(N):
    print(node_colors[i+1]) i range(N) range N print(node_colors[i+1]) print node_colors[i+1] node_colors i+1 i 1 u, v, w = map(int,input().split()) map(int,input().split()) u def route(last, now, dist):
    for next_node, next_distance in paths[now].items():
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance) def route(last, now, dist):
    for next_node, next_distance in paths[now].items():
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance) route node_colors = [-1] * (N+1) [-1] * (N+1) node_colors N = int(input()) int(input()) N v, w = map(int,input().split()) map(int,input().split()) v w = map(int,input().split()) map(int,input().split()) w paths = [dict() for i in range(N + 1)] [dict() for i in range(N + 1)] paths
import sys
sys.setrecursionlimit(10**6)

N = int(input())
paths = [dict() for i in range(N + 1)]
for i in range(N-1):
    u, v, w = map(int,input().split())
    paths[u][v] = w
    paths[v][u] = w

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in paths[now].items():
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])
