class Graph():
	def __init__(self):
		self.adjacency_dict = {}
		self.weight = []

	def add_vartex(self, v):
		self.adjacency_dict[v] = []
		self.weight.append([])

	def add_edge(self, v1, v2, w):
		self.adjacency_dict[v1].append(v2)
		self.adjacency_dict[v2].append(v1)
		self.weight[v1].append(w)
		self.weight[v2].append(w)

	def get_vartexes(self):
		return self.adjacency_dict.keys()

	def get_edges(self, v):
		return self.adjacency_dict[v], self.weight[v]

	def printgraph(self):
		return print(self.adjacency_dict)

n = int(input())

res = []
g = Graph()
for i in range(n):
	res.append(-1)
	g.add_vartex(i)

for i in range(n-1):
	u, v, w = map(int, input().strip().split())
	g.add_edge(u - 1, v - 1, w % 2)


q = []
res[0] = 0
q.append(0)
while(len(q) > 0):
	v = q.pop()
	u_l, w_l = g.get_edges(v)
	for u, w in zip(u_l, w_l):
		if res[u] != -1:
			continue
		res[u] = (res[v] + w) % 2
		q.append(u)

for i in range(n):
	print(res[i])
 class Graph():
	def __init__(self):
		self.adjacency_dict = {}
		self.weight = []

	def add_vartex(self, v):
		self.adjacency_dict[v] = []
		self.weight.append([])

	def add_edge(self, v1, v2, w):
		self.adjacency_dict[v1].append(v2)
		self.adjacency_dict[v2].append(v1)
		self.weight[v1].append(w)
		self.weight[v2].append(w)

	def get_vartexes(self):
		return self.adjacency_dict.keys()

	def get_edges(self, v):
		return self.adjacency_dict[v], self.weight[v]

	def printgraph(self):
		return print(self.adjacency_dict) Graph def __init__(self):
		self.adjacency_dict = {}
		self.weight = []

	 __init__ self.adjacency_dict = {} self.adjacency_dict self adjacency_dict {} self.weight = [] self.weight self weight [] self self def add_vartex(self, v):
		self.adjacency_dict[v] = []
		self.weight.append([])

	 add_vartex self.adjacency_dict[v] = [] self.adjacency_dict[v] self.adjacency_dict self adjacency_dict v [] self.weight.append([]) self.weight.append self.weight self weight append [] self self v v def add_edge(self, v1, v2, w):
		self.adjacency_dict[v1].append(v2)
		self.adjacency_dict[v2].append(v1)
		self.weight[v1].append(w)
		self.weight[v2].append(w)

	 add_edge self.adjacency_dict[v1].append(v2) self.adjacency_dict[v1].append self.adjacency_dict[v1] self.adjacency_dict self adjacency_dict v1 append v2 self.adjacency_dict[v2].append(v1) self.adjacency_dict[v2].append self.adjacency_dict[v2] self.adjacency_dict self adjacency_dict v2 append v1 self.weight[v1].append(w) self.weight[v1].append self.weight[v1] self.weight self weight v1 append w self.weight[v2].append(w) self.weight[v2].append self.weight[v2] self.weight self weight v2 append w self self v1 v1 v2 v2 w w def get_vartexes(self):
		return self.adjacency_dict.keys()

	 get_vartexes return self.adjacency_dict.keys() self.adjacency_dict.keys() self.adjacency_dict.keys self.adjacency_dict self adjacency_dict keys self self def get_edges(self, v):
		return self.adjacency_dict[v], self.weight[v]

	 get_edges return self.adjacency_dict[v], self.weight[v] return self.adjacency_dict[v], self.weight[v] self.adjacency_dict[v] self.adjacency_dict self adjacency_dict v self.weight[v] self.weight self weight v self self v v def printgraph(self):
		return print(self.adjacency_dict) printgraph return print(self.adjacency_dict) print(self.adjacency_dict) print self.adjacency_dict self adjacency_dict self self n = int(input()) n int(input()) int input() input res = [] res [] g = Graph() g Graph() Graph for i in range(n):
	res.append(-1)
	g.add_vartex(i) i range(n) range n res.append(-1) res.append res append -1 g.add_vartex(i) g.add_vartex g add_vartex i for i in range(n-1):
	u, v, w = map(int, input().strip().split())
	g.add_edge(u - 1, v - 1, w % 2) i range(n-1) range n-1 n 1 u, v, w = map(int, input().strip().split()) u map(int, input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split v w g.add_edge(u - 1, v - 1, w % 2) g.add_edge g add_edge u - 1 u 1 v - 1 v 1 w % 2 w 2 q = [] q [] res[0] = 0 res[0] res 0 0 q.append(0) q.append q append 0 while(len(q) > 0):
	v = q.pop()
	u_l, w_l = g.get_edges(v)
	for u, w in zip(u_l, w_l):
		if res[u] != -1:
			continue
		res[u] = (res[v] + w) % 2
		q.append(u) len(q) > 0 len(q) len q 0 v = q.pop() v q.pop() q.pop q pop u_l, w_l = g.get_edges(v) u_l g.get_edges(v) g.get_edges g get_edges v w_l for u, w in zip(u_l, w_l):
		if res[u] != -1:
			continue
		res[u] = (res[v] + w) % 2
		q.append(u) u w zip(u_l, w_l) zip u_l w_l if res[u] != -1:
			continue
		 res[u] != -1 res[u] res u -1 continue res[u] = (res[v] + w) % 2 res[u] res u (res[v] + w) % 2 res[v] + w res[v] res v w 2 q.append(u) q.append q append u for i in range(n):
	print(res[i]) i range(n) range n print(res[i]) print res[i] res i u, v, w = map(int, input().strip().split()) map(int, input().strip().split()) u n = int(input()) int(input()) n class Graph():
	def __init__(self):
		self.adjacency_dict = {}
		self.weight = []

	def add_vartex(self, v):
		self.adjacency_dict[v] = []
		self.weight.append([])

	def add_edge(self, v1, v2, w):
		self.adjacency_dict[v1].append(v2)
		self.adjacency_dict[v2].append(v1)
		self.weight[v1].append(w)
		self.weight[v2].append(w)

	def get_vartexes(self):
		return self.adjacency_dict.keys()

	def get_edges(self, v):
		return self.adjacency_dict[v], self.weight[v]

	def printgraph(self):
		return print(self.adjacency_dict) class Graph():
	def __init__(self):
		self.adjacency_dict = {}
		self.weight = []

	def add_vartex(self, v):
		self.adjacency_dict[v] = []
		self.weight.append([])

	def add_edge(self, v1, v2, w):
		self.adjacency_dict[v1].append(v2)
		self.adjacency_dict[v2].append(v1)
		self.weight[v1].append(w)
		self.weight[v2].append(w)

	def get_vartexes(self):
		return self.adjacency_dict.keys()

	def get_edges(self, v):
		return self.adjacency_dict[v], self.weight[v]

	def printgraph(self):
		return print(self.adjacency_dict) Graph g = Graph() Graph() g w_l = g.get_edges(v) g.get_edges(v) w_l res = [] [] res q = [] [] q v = q.pop() q.pop() v v, w = map(int, input().strip().split()) map(int, input().strip().split()) v w = map(int, input().strip().split()) map(int, input().strip().split()) w u_l, w_l = g.get_edges(v) g.get_edges(v) u_l
class Graph():
	def __init__(self):
		self.adjacency_dict = {}
		self.weight = []

	def add_vartex(self, v):
		self.adjacency_dict[v] = []
		self.weight.append([])

	def add_edge(self, v1, v2, w):
		self.adjacency_dict[v1].append(v2)
		self.adjacency_dict[v2].append(v1)
		self.weight[v1].append(w)
		self.weight[v2].append(w)

	def get_vartexes(self):
		return self.adjacency_dict.keys()

	def get_edges(self, v):
		return self.adjacency_dict[v], self.weight[v]

	def printgraph(self):
		return print(self.adjacency_dict)

n = int(input())

res = []
g = Graph()
for i in range(n):
	res.append(-1)
	g.add_vartex(i)

for i in range(n-1):
	u, v, w = map(int, input().strip().split())
	g.add_edge(u - 1, v - 1, w % 2)


q = []
res[0] = 0
q.append(0)
while(len(q) > 0):
	v = q.pop()
	u_l, w_l = g.get_edges(v)
	for u, w in zip(u_l, w_l):
		if res[u] != -1:
			continue
		res[u] = (res[v] + w) % 2
		q.append(u)

for i in range(n):
	print(res[i])

