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

def dfs(start,n,g):
    visited = [-1]*(n+1)
    visited[start] = 0
    stack = deque([start])
    while stack:
        c_node = stack.pop()
        for neib, dist in g[c_node]:
            if visited[neib] != -1: continue
            visited[neib] = visited[c_node] + dist
            stack.append(neib)
    return visited
    

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))

visited = dfs(1,N,g)
for p in visited[1:]:
    print(p%2)
    
 import sys sys from collections import deque 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(start,n,g):
    visited = [-1]*(n+1)
    visited[start] = 0
    stack = deque([start])
    while stack:
        c_node = stack.pop()
        for neib, dist in g[c_node]:
            if visited[neib] != -1: continue
            visited[neib] = visited[c_node] + dist
            stack.append(neib)
    return visited
     dfs visited = [-1]*(n+1) visited [-1]*(n+1) [-1] -1 n+1 n 1 visited[start] = 0 visited[start] visited start 0 stack = deque([start]) stack deque([start]) deque [start] start while stack:
        c_node = stack.pop()
        for neib, dist in g[c_node]:
            if visited[neib] != -1: continue
            visited[neib] = visited[c_node] + dist
            stack.append(neib)
     stack c_node = stack.pop() c_node stack.pop() stack.pop stack pop for neib, dist in g[c_node]:
            if visited[neib] != -1: continue
            visited[neib] = visited[c_node] + dist
            stack.append(neib)
     neib dist g[c_node] g c_node if visited[neib] != -1: continue
             visited[neib] != -1 visited[neib] visited neib -1 visited[neib] = visited[c_node] + dist visited[neib] visited neib visited[c_node] + dist visited[c_node] visited c_node dist stack.append(neib) stack.append stack append neib return visited visited start start n n 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 visited = dfs(1,N,g) visited dfs(1,N,g) dfs 1 N g for p in visited[1:]:
    print(p%2)
     p visited[1:] visited 1: 1 print(p%2) print p%2 p 2 input = sys.stdin.readline sys.stdin.readline input visited = dfs(1,N,g) dfs(1,N,g) visited N = int(input()) int(input()) N g = [ [] for _ in range(N+1)] [ [] for _ in range(N+1)] g v, w = map(int, input().split()) map(int, input().split()) v def dfs(start,n,g):
    visited = [-1]*(n+1)
    visited[start] = 0
    stack = deque([start])
    while stack:
        c_node = stack.pop()
        for neib, dist in g[c_node]:
            if visited[neib] != -1: continue
            visited[neib] = visited[c_node] + dist
            stack.append(neib)
    return visited
     def dfs(start,n,g):
    visited = [-1]*(n+1)
    visited[start] = 0
    stack = deque([start])
    while stack:
        c_node = stack.pop()
        for neib, dist in g[c_node]:
            if visited[neib] != -1: continue
            visited[neib] = visited[c_node] + dist
            stack.append(neib)
    return visited
     dfs visited = [-1] * (N+1) [-1] * (N+1) visited u, v, w = map(int, input().split()) map(int, input().split()) u w%=2 2 w w = map(int, input().split()) map(int, input().split()) w
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(start,n,g):
    visited = [-1]*(n+1)
    visited[start] = 0
    stack = deque([start])
    while stack:
        c_node = stack.pop()
        for neib, dist in g[c_node]:
            if visited[neib] != -1: continue
            visited[neib] = visited[c_node] + dist
            stack.append(neib)
    return visited
    

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))

visited = dfs(1,N,g)
for p in visited[1:]:
    print(p%2)
    

