"""dfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())
 
G = {}
for i in range(n):
    G.update({i:[]})

for i in range(n-1):
    u,v,w = map(int, input().split())
    u -= 1; v -= 1
    G[u].append([v, w%2])
    G[v].append([u, w%2])

color = [-1 for i in range(n)]

def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        if color[next_v[0]] != -1: continue
        dist = next_v[1]
        if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
        dfs(graph, next_v[0], next_c)

dfs(G, 0, 0)

print(*color) """dfs""" import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 n = int(input()) n int(input()) int input() input G = {} G {} for i in range(n):
    G.update({i:[]}) i range(n) range n G.update({i:[]}) G.update G update {i:[]} i i [] for i in range(n-1):
    u,v,w = map(int, input().split())
    u -= 1; v -= 1
    G[u].append([v, w%2])
    G[v].append([u, w%2]) 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 u -= 1 u 1 v -= 1 v 1 G[u].append([v, w%2]) [u].append [u] G u append [v, w%2] v w%2 w 2 G[v].append([u, w%2]) [v].append [v] G v append [u, w%2] u w%2 w 2 -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 color = [-1 for i in range(n)] color [-1 for i in range(n)] def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        if color[next_v[0]] != -1: continue
        dist = next_v[1]
        if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
        dfs(graph, next_v[0], next_c) dfs color[v] = c color[v] color v c for next_v in graph[v]:
        if color[next_v[0]] != -1: continue
        dist = next_v[1]
        if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
        dfs(graph, next_v[0], next_c) next_v graph[v] graph v if color[next_v[0]] != -1: continue
         color[next_v[0]] != -1 color[next_v[0]] color next_v[0] next_v 0 -1 dist = next_v[1] dist next_v[1] next_v 1 if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
         dist == 0 dist 0 next_c = c next_c c elif dist == 1:
            next_c = 1 - c
        
         dist == 1 dist 1 next_c = 1 - c next_c 1 - c 1 c dfs(graph, next_v[0], next_c) dfs graph next_v[0] next_v 0 next_c graph graph v v c c dfs(G, 0, 0) dfs G 0 0 print(*color) print *color color v,w = map(int, input().split()) map(int, input().split()) v w = map(int, input().split()) map(int, input().split()) w u -= 1 1 u v -= 1 1 v def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        if color[next_v[0]] != -1: continue
        dist = next_v[1]
        if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
        dfs(graph, next_v[0], next_c) def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        if color[next_v[0]] != -1: continue
        dist = next_v[1]
        if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
        dfs(graph, next_v[0], next_c) dfs u,v,w = map(int, input().split()) map(int, input().split()) u n = int(input()) int(input()) n G = {} {} G color = [-1 for i in range(n)] [-1 for i in range(n)] color
"""dfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())
 
G = {}
for i in range(n):
    G.update({i:[]})

for i in range(n-1):
    u,v,w = map(int, input().split())
    u -= 1; v -= 1
    G[u].append([v, w%2])
    G[v].append([u, w%2])

color = [-1 for i in range(n)]

def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        if color[next_v[0]] != -1: continue
        dist = next_v[1]
        if dist == 0:
            next_c = c
        elif dist == 1:
            next_c = 1 - c
        
        dfs(graph, next_v[0], next_c)

dfs(G, 0, 0)

print(*color)