import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(curr_v, pare_v, curr_sum, visited, g):
    if curr_sum%2 == 0:
        visited[curr_v] = 0
    else:
        visited[curr_v] = 1
    for neib_vw in g[curr_v]:
        if neib_vw[0] == pare_v: continue
        dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g)
    

N = int(input())
g = [ [] for _ in range(N+1)]
visited = [-1] * (N+1)

for _ in range(N-1):
    u, v, w = map(int, input().split()) 
    w%=2
    g[u].append((v,w))
    g[v].append((u,w))

dfs(1, -1, 0, visited, g)
for p in visited[1:]:
    print(p)
    
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 def dfs(curr_v, pare_v, curr_sum, visited, g):
    if curr_sum%2 == 0:
        visited[curr_v] = 0
    else:
        visited[curr_v] = 1
    for neib_vw in g[curr_v]:
        if neib_vw[0] == pare_v: continue
        dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g)
     dfs if curr_sum%2 == 0:
        visited[curr_v] = 0
    else:
        visited[curr_v] = 1
     curr_sum%2 == 0 curr_sum%2 curr_sum 2 0 visited[curr_v] = 0 visited[curr_v] visited curr_v 0 visited[curr_v] = 1 visited[curr_v] visited curr_v 1 for neib_vw in g[curr_v]:
        if neib_vw[0] == pare_v: continue
        dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g)
     neib_vw g[curr_v] g curr_v if neib_vw[0] == pare_v: continue
         neib_vw[0] == pare_v neib_vw[0] neib_vw 0 pare_v dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g) dfs neib_vw[0] neib_vw 0 curr_v curr_sum+neib_vw[1] curr_sum neib_vw[1] neib_vw 1 visited g curr_v curr_v pare_v pare_v curr_sum curr_sum visited visited g g N = int(input()) N int(input()) int input() input [] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] g = [ [] for _ in range(N+1)] g [ [] for _ in range(N+1)] visited = [-1] * (N+1) visited [-1] * (N+1) [-1] -1 N+1 N 1 for _ in range(N-1):
    u, v, w = map(int, input().split()) 
    w%=2
    g[u].append((v,w))
    g[v].append((u,w)) _ 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 w%=2 w 2 g[u].append((v,w)) [u].append [u] g u append (v,w) v w g[v].append((u,w)) [v].append [v] g v append (u,w) u w dfs(1, -1, 0, visited, g) dfs 1 -1 0 visited g for p in visited[1:]:
    print(p)
     p visited[1:] visited 1: 1 print(p) print p def dfs(curr_v, pare_v, curr_sum, visited, g):
    if curr_sum%2 == 0:
        visited[curr_v] = 0
    else:
        visited[curr_v] = 1
    for neib_vw in g[curr_v]:
        if neib_vw[0] == pare_v: continue
        dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g)
     def dfs(curr_v, pare_v, curr_sum, visited, g):
    if curr_sum%2 == 0:
        visited[curr_v] = 0
    else:
        visited[curr_v] = 1
    for neib_vw in g[curr_v]:
        if neib_vw[0] == pare_v: continue
        dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g)
     dfs u, v, w = map(int, input().split()) map(int, input().split()) u v, w = map(int, input().split()) map(int, input().split()) v w%=2 2 w visited = [-1] * (N+1) [-1] * (N+1) visited g = [ [] for _ in range(N+1)] [ [] for _ in range(N+1)] g N = int(input()) int(input()) N input = sys.stdin.readline sys.stdin.readline input w = map(int, input().split()) map(int, input().split()) w
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(curr_v, pare_v, curr_sum, visited, g):
    if curr_sum%2 == 0:
        visited[curr_v] = 0
    else:
        visited[curr_v] = 1
    for neib_vw in g[curr_v]:
        if neib_vw[0] == pare_v: continue
        dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g)
    

N = int(input())
g = [ [] for _ in range(N+1)]
visited = [-1] * (N+1)

for _ in range(N-1):
    u, v, w = map(int, input().split()) 
    w%=2
    g[u].append((v,w))
    g[v].append((u,w))

dfs(1, -1, 0, visited, g)
for p in visited[1:]:
    print(p)
    

