import sys
import copy
sys.setrecursionlimit(10**7)
def dfs(graph,v,dist_mod):
    color[v] = dist_mod
    for next_v,dist in graph[v]:
        if color[next_v] != -1:
            continue
        dfs(graph,next_v,(dist_mod+dist)%2)
n = int(input())
uvw = [list(map(int,input().split())) for _ in range(n-1)]
g = [[] for _ in range(n)]
color = [-1]*n
for i in range(n-1):
    g[uvw[i][0]-1].append([uvw[i][1]-1,uvw[i][2]])
    g[uvw[i][1]-1].append([uvw[i][0]-1,uvw[i][2]])
dfs(g,0,0)
for i in range(n):
    print(color[i]) import sys sys import copy copy sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 def dfs(graph,v,dist_mod):
    color[v] = dist_mod
    for next_v,dist in graph[v]:
        if color[next_v] != -1:
            continue
        dfs(graph,next_v,(dist_mod+dist)%2) dfs color[v] = dist_mod color[v] color v dist_mod for next_v,dist in graph[v]:
        if color[next_v] != -1:
            continue
        dfs(graph,next_v,(dist_mod+dist)%2) next_v dist graph[v] graph v if color[next_v] != -1:
            continue
         color[next_v] != -1 color[next_v] color next_v -1 continue dfs(graph,next_v,(dist_mod+dist)%2) dfs graph next_v (dist_mod+dist)%2 dist_mod+dist dist_mod dist 2 graph graph v v dist_mod dist_mod n = int(input()) n int(input()) int input() input list(map(int,input().split())) for _ in range(n-1) for _ in range(n-1) _ range(n-1) range n-1 n 1 for _ in range(n-1) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split uvw = [list(map(int,input().split())) for _ in range(n-1)] uvw [list(map(int,input().split())) for _ in range(n-1)] [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] g = [[] for _ in range(n)] g [[] for _ in range(n)] color = [-1]*n color [-1]*n [-1] -1 n for i in range(n-1):
    g[uvw[i][0]-1].append([uvw[i][1]-1,uvw[i][2]])
    g[uvw[i][1]-1].append([uvw[i][0]-1,uvw[i][2]]) i range(n-1) range n-1 n 1 g[uvw[i][0]-1].append([uvw[i][1]-1,uvw[i][2]]) [uvw[i][0]-1].append [uvw[i][0]-1] g uvw[i][0]-1 uvw[i][0] [i] uvw i 0 1 append [uvw[i][1]-1,uvw[i][2]] uvw[i][1]-1 uvw[i][1] [i] uvw i 1 1 uvw[i][2] [i] uvw i 2 g[uvw[i][1]-1].append([uvw[i][0]-1,uvw[i][2]]) [uvw[i][1]-1].append [uvw[i][1]-1] g uvw[i][1]-1 uvw[i][1] [i] uvw i 1 1 append [uvw[i][0]-1,uvw[i][2]] uvw[i][0]-1 uvw[i][0] [i] uvw i 0 1 uvw[i][2] [i] uvw i 2 dfs(g,0,0) dfs g 0 0 for i in range(n):
    print(color[i]) i range(n) range n print(color[i]) print color[i] color i color = [-1]*n [-1]*n color def dfs(graph,v,dist_mod):
    color[v] = dist_mod
    for next_v,dist in graph[v]:
        if color[next_v] != -1:
            continue
        dfs(graph,next_v,(dist_mod+dist)%2) def dfs(graph,v,dist_mod):
    color[v] = dist_mod
    for next_v,dist in graph[v]:
        if color[next_v] != -1:
            continue
        dfs(graph,next_v,(dist_mod+dist)%2) dfs uvw = [list(map(int,input().split())) for _ in range(n-1)] [list(map(int,input().split())) for _ in range(n-1)] uvw n = int(input()) int(input()) n g = [[] for _ in range(n)] [[] for _ in range(n)] g
import sys
import copy
sys.setrecursionlimit(10**7)
def dfs(graph,v,dist_mod):
    color[v] = dist_mod
    for next_v,dist in graph[v]:
        if color[next_v] != -1:
            continue
        dfs(graph,next_v,(dist_mod+dist)%2)
n = int(input())
uvw = [list(map(int,input().split())) for _ in range(n-1)]
g = [[] for _ in range(n)]
color = [-1]*n
for i in range(n-1):
    g[uvw[i][0]-1].append([uvw[i][1]-1,uvw[i][2]])
    g[uvw[i][1]-1].append([uvw[i][0]-1,uvw[i][2]])
dfs(g,0,0)
for i in range(n):
    print(color[i])