import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
edges = defaultdict(list)
for i in range(N-1):
	u, v, w = rl()
	u, v = u-1, v-1
	edges[u].append((v,w))
	edges[v].append((u,w))

visited = {}
colors = [None] * N
colors[0] = 0
def dfs(node, prev=-1):
	if node in visited: return
	visited[node] = 1
	color = colors[node]
	for next_node, dist in edges[node]:
		if next_node == prev: continue
		if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		dfs(next_node, node)
dfs(0)
for c in colors:
	print(c) import sys, math sys math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline rs = lambda: input().strip() rs lambda: input().strip() input().strip() ().strip () input strip ri = lambda: int(input()) ri lambda: int(input()) int(input()) int input() input rl = lambda: list(map(int, input().split())) rl lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split [v]*y for _ in range(x) for _ in range(x) _ range(x) range x for _ in range(x) [v]*y [v] v y mat = lambda x, y, v: [[v]*y for _ in range(x)] mat lambda x, y, v: [[v]*y for _ in range(x)] [[v]*y for _ in range(x)] x y v mat(y, z, v) for _ in range(x) for _ in range(x) _ range(x) range x for _ in range(x) mat(y, z, v) mat y z v ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)] ten lambda x, y, z, v: [mat(y, z, v) for _ in range(x)] [mat(y, z, v) for _ in range(x)] x y z v mod = 1000000007 mod 1000000007 sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 N = ri() N ri() ri edges = defaultdict(list) edges defaultdict(list) defaultdict list for i in range(N-1):
	u, v, w = rl()
	u, v = u-1, v-1
	edges[u].append((v,w))
	edges[v].append((u,w)) i range(N-1) range N-1 N 1 u, v, w = rl() u rl() rl v w u, v = u-1, v-1 u u-1 u 1 v v-1 v 1 edges[u].append((v,w)) [u].append [u] edges u append (v,w) v w edges[v].append((u,w)) [v].append [v] edges v append (u,w) u w visited = {} visited {} colors = [None] * N colors [None] * N [None] None N colors[0] = 0 colors[0] colors 0 0 def dfs(node, prev=-1):
	if node in visited: return
	visited[node] = 1
	color = colors[node]
	for next_node, dist in edges[node]:
		if next_node == prev: continue
		if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		dfs(next_node, node) dfs if node in visited: return
	 node in visited node visited visited[node] = 1 visited[node] visited node 1 color = colors[node] color colors[node] colors node for next_node, dist in edges[node]:
		if next_node == prev: continue
		if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		dfs(next_node, node) next_node dist edges[node] edges node if next_node == prev: continue
		 next_node == prev next_node prev if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		 dist % 2 == 0 dist % 2 dist 2 0 colors[next_node] = colors[node] colors[next_node] colors next_node colors[node] colors node colors[next_node] = int(not colors[node]) colors[next_node] colors next_node int(not colors[node]) int not colors[node] colors[node] colors node dfs(next_node, node) dfs next_node node node node prev=-1 prev -1 dfs(0) dfs 0 for c in colors:
	print(c) c colors print(c) print c colors = [None] * N [None] * N colors mat = lambda x, y, v: [[v]*y for _ in range(x)] lambda x, y, v: [[v]*y for _ in range(x)] mat v = u-1, v-1 v-1 v ri = lambda: int(input()) lambda: int(input()) ri input = sys.stdin.readline sys.stdin.readline input rs = lambda: input().strip() lambda: input().strip() rs edges = defaultdict(list) defaultdict(list) edges N = ri() ri() N v, w = rl() rl() v visited = {} {} visited def dfs(node, prev=-1):
	if node in visited: return
	visited[node] = 1
	color = colors[node]
	for next_node, dist in edges[node]:
		if next_node == prev: continue
		if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		dfs(next_node, node) def dfs(node, prev=-1):
	if node in visited: return
	visited[node] = 1
	color = colors[node]
	for next_node, dist in edges[node]:
		if next_node == prev: continue
		if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		dfs(next_node, node) dfs w = rl() rl() w ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)] lambda x, y, z, v: [mat(y, z, v) for _ in range(x)] ten rl = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) rl u, v, w = rl() rl() u u, v = u-1, v-1 u-1 u mod = 1000000007 1000000007 mod
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
edges = defaultdict(list)
for i in range(N-1):
	u, v, w = rl()
	u, v = u-1, v-1
	edges[u].append((v,w))
	edges[v].append((u,w))

visited = {}
colors = [None] * N
colors[0] = 0
def dfs(node, prev=-1):
	if node in visited: return
	visited[node] = 1
	color = colors[node]
	for next_node, dist in edges[node]:
		if next_node == prev: continue
		if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		dfs(next_node, node)
dfs(0)
for c in colors:
	print(c)
