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


q = collections.deque([(1,0)])
h = { 1:0 }
while(q):
	u,c = q.popleft()
	for v,w in adj[u]:
		if v not in h:
			h[v] = (1- c) if (w % 2) else c
			q.append((v,h[v]))

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 q = collections.deque([(1,0)]) q collections.deque([(1,0)]) collections.deque collections deque [(1,0)] (1,0) 1 0 h = { 1:0 } h { 1:0 } 1 1 0 while(q):
	u,c = q.popleft()
	for v,w in adj[u]:
		if v not in h:
			h[v] = (1- c) if (w % 2) else c
			q.append((v,h[v])) q u,c = q.popleft() u q.popleft() q.popleft q popleft c for v,w in adj[u]:
		if v not in h:
			h[v] = (1- c) if (w % 2) else c
			q.append((v,h[v])) v w adj[u] adj u if v not in h:
			h[v] = (1- c) if (w % 2) else c
			q.append((v,h[v])) v not in h v h h[v] = (1- c) if (w % 2) else c h[v] h v (1- c) if (w % 2) else c w % 2 w 2 1- c 1 c c q.append((v,h[v])) q.append q append (v,h[v]) v h[v] h v for node in range(1, n + 1): 
	print h[node] node range(1, n + 1) range 1 n + 1 n 1 print h[node] h node adj = collections.defaultdict(list) collections.defaultdict(list) adj w = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) w q = collections.deque([(1,0)]) collections.deque([(1,0)]) q c = q.popleft() q.popleft() c u,c = q.popleft() q.popleft() u n = int(raw_input()) int(raw_input()) n u, v, w = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) u v, w = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) v h = { 1:0 } { 1:0 } h
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))


q = collections.deque([(1,0)])
h = { 1:0 }
while(q):
	u,c = q.popleft()
	for v,w in adj[u]:
		if v not in h:
			h[v] = (1- c) if (w % 2) else c
			q.append((v,h[v]))

for node in range(1, n + 1): 
	print h[node]