import sys
sys.setrecursionlimit(200000)

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

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())
    G[u - 1].append([v - 1, w % 2])
    G[v - 1].append([u - 1, w % 2])
 
color = [-1 for i in range(n)]
 
def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        dis = next_v[1]
        if color[next_v[0]] != -1:
            continue
        
        if dis == 0:
            n_c = c
        elif dis == 1:
            n_c = 1 - c
        
        dfs(graph, next_v[0], n_c)
 
dfs(G, 0, 0)
[print(i) for i in color]