import collections
n = int(raw_input())
adj = collections.defaultdict(list)
for _ in range(n - 1):
	u, v, w = map(int, raw_input().split(' '))
	adj[u].append((v,w))
	adj[v].append((u,w))
h = [-1 for _ in range(n+1)]
h[1] = 0
def dfs(h, adj):
	stack = collections.deque([1])
	while(stack):
		u = stack.pop()
		for v,w in adj[u]:
			if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj)
dfs(h, adj)
for node in range(1, n + 1):  print h[node] import collections collections n = int(raw_input()) n int(raw_input()) int raw_input() raw_input adj = collections.defaultdict(list) adj collections.defaultdict(list) collections.defaultdict collections defaultdict list for _ in range(n - 1):
	u, v, w = map(int, raw_input().split(' '))
	adj[u].append((v,w))
	adj[v].append((u,w)) _ range(n - 1) range n - 1 n 1 u, v, w = map(int, raw_input().split(' ')) u map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' v w adj[u].append((v,w)) [u].append [u] adj u append (v,w) v w adj[v].append((u,w)) [v].append [v] adj v append (u,w) u w -1 for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) -1 h = [-1 for _ in range(n+1)] h [-1 for _ in range(n+1)] h[1] = 0 h[1] h 1 0 def dfs(h, adj):
	stack = collections.deque([1])
	while(stack):
		u = stack.pop()
		for v,w in adj[u]:
			if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj) dfs stack = collections.deque([1]) stack collections.deque([1]) collections.deque collections deque [1] 1 while(stack):
		u = stack.pop()
		for v,w in adj[u]:
			if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj) stack u = stack.pop() u stack.pop() stack.pop stack pop for v,w in adj[u]:
			if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj) v w adj[u] adj u if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj) h[v] == -1 h[v] h v -1 h[v] = (1- h[u]) if (w % 2) else h[u] h[v] h v (1- h[u]) if (w % 2) else h[u] w % 2 w 2 1- h[u] 1 h[u] h u h[u] h u stack.append(v) stack.append stack append v h h adj adj dfs(h, adj) dfs h adj for node in range(1, n + 1):  print node range(1, n + 1) range 1 n + 1 n 1 h[node] h node u, v, w = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) u h = [-1 for _ in range(n+1)] [-1 for _ in range(n+1)] h adj = collections.defaultdict(list) collections.defaultdict(list) adj v, w = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) v w = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) w n = int(raw_input()) int(raw_input()) n def dfs(h, adj):
	stack = collections.deque([1])
	while(stack):
		u = stack.pop()
		for v,w in adj[u]:
			if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj) def dfs(h, adj):
	stack = collections.deque([1])
	while(stack):
		u = stack.pop()
		for v,w in adj[u]:
			if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj) dfs
import collections
n = int(raw_input())
adj = collections.defaultdict(list)
for _ in range(n - 1):
	u, v, w = map(int, raw_input().split(' '))
	adj[u].append((v,w))
	adj[v].append((u,w))
h = [-1 for _ in range(n+1)]
h[1] = 0
def dfs(h, adj):
	stack = collections.deque([1])
	while(stack):
		u = stack.pop()
		for v,w in adj[u]:
			if h[v] == -1:
				h[v] = (1- h[u]) if (w % 2) else h[u]
				stack.append(v) #(v, h, adj)
dfs(h, adj)
for node in range(1, n + 1):  print h[node]