import sys
sys.setrecursionlimit(10**7)
from collections import defaultdict
def dfs(node_i, oe):
    if ans[node_i] != -1:
        return
    next_nodes = graph[node_i]
    ans[node_i] = oe
    for next_i, cost in next_nodes:
        dfs(next_i, (oe+cost)%2)
        

N = int(input())
ans = [-1 for i in range(N+1)]
graph = defaultdict(list)
for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u] += [(v, w)]
    graph[v] += [(u, w)]

dfs(1, 0)
for i in range(1, N+1):
    print(ans[i]) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import defaultdict def dfs(node_i, oe):
    if ans[node_i] != -1:
        return
    next_nodes = graph[node_i]
    ans[node_i] = oe
    for next_i, cost in next_nodes:
        dfs(next_i, (oe+cost)%2)
         dfs if ans[node_i] != -1:
        return
     ans[node_i] != -1 ans[node_i] ans node_i -1 return next_nodes = graph[node_i] next_nodes graph[node_i] graph node_i ans[node_i] = oe ans[node_i] ans node_i oe for next_i, cost in next_nodes:
        dfs(next_i, (oe+cost)%2)
         next_i cost next_nodes dfs(next_i, (oe+cost)%2) dfs next_i (oe+cost)%2 oe+cost oe cost 2 node_i node_i oe oe N = int(input()) N int(input()) int input() input -1 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) -1 ans = [-1 for i in range(N+1)] ans [-1 for i in range(N+1)] graph = defaultdict(list) graph defaultdict(list) defaultdict list for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u] += [(v, w)]
    graph[v] += [(u, w)] 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 graph[u] += [(v, w)] graph[u] graph u [(v, w)] (v, w) v w graph[v] += [(u, w)] graph[v] graph v [(u, w)] (u, w) u w dfs(1, 0) dfs 1 0 for i in range(1, N+1):
    print(ans[i]) i range(1, N+1) range 1 N+1 N 1 print(ans[i]) print ans[i] ans i w = map(int, input().split()) map(int, input().split()) w u, v, w = map(int, input().split()) map(int, input().split()) u graph = defaultdict(list) defaultdict(list) graph v, w = map(int, input().split()) map(int, input().split()) v def dfs(node_i, oe):
    if ans[node_i] != -1:
        return
    next_nodes = graph[node_i]
    ans[node_i] = oe
    for next_i, cost in next_nodes:
        dfs(next_i, (oe+cost)%2)
         def dfs(node_i, oe):
    if ans[node_i] != -1:
        return
    next_nodes = graph[node_i]
    ans[node_i] = oe
    for next_i, cost in next_nodes:
        dfs(next_i, (oe+cost)%2)
         dfs N = int(input()) int(input()) N ans = [-1 for i in range(N+1)] [-1 for i in range(N+1)] ans
import sys
sys.setrecursionlimit(10**7)
from collections import defaultdict
def dfs(node_i, oe):
    if ans[node_i] != -1:
        return
    next_nodes = graph[node_i]
    ans[node_i] = oe
    for next_i, cost in next_nodes:
        dfs(next_i, (oe+cost)%2)
        

N = int(input())
ans = [-1 for i in range(N+1)]
graph = defaultdict(list)
for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u] += [(v, w)]
    graph[v] += [(u, w)]

dfs(1, 0)
for i in range(1, N+1):
    print(ans[i])