# distance between two nodes is dis(root, a)+dis(root, b)-2*(dis(lca(a,b),root))
# taking mod 2 last term is eliminated 
# all nodes having dis as odd parity from root will be white color
# all nodes having dis as even parity from root will be even color
import sys
import os
sys.setrecursionlimit(1000000)
from collections import defaultdict
adj = defaultdict(list)
dis =[0 for i in range(1000000)]
def dfs(u , p):
	for i , w in adj[u]:
		if i==p:
			continue
		dis[i]=dis[u]+w
		dis[i]=dis[i]%2
		dfs(i , u)
def main():
	n = int(input())
	for i in range(n-1):
		x, y , w = map(int , input().split())
		w = w%2
		adj[x].append([y , w])
		adj[y].append([x, w])
	dfs(1, 0)
	for i in range(1,n+1):
		print(dis[i])
if __name__ =="__main__":
	main() import sys sys import os os sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 from collections import defaultdict adj = defaultdict(list) adj defaultdict(list) defaultdict list 0 for i in range(1000000) for i in range(1000000) i range(1000000) range 1000000 for i in range(1000000) 0 dis =[0 for i in range(1000000)] dis [0 for i in range(1000000)] def dfs(u , p):
	for i , w in adj[u]:
		if i==p:
			continue
		dis[i]=dis[u]+w
		dis[i]=dis[i]%2
		dfs(i , u) dfs for i , w in adj[u]:
		if i==p:
			continue
		dis[i]=dis[u]+w
		dis[i]=dis[i]%2
		dfs(i , u) i w adj[u] adj u if i==p:
			continue
		 i==p i p continue dis[i]=dis[u]+w dis[i] dis i dis[u]+w dis[u] dis u w dis[i]=dis[i]%2 dis[i] dis i dis[i]%2 dis[i] dis i 2 dfs(i , u) dfs i u u u p p def main():
	n = int(input())
	for i in range(n-1):
		x, y , w = map(int , input().split())
		w = w%2
		adj[x].append([y , w])
		adj[y].append([x, w])
	dfs(1, 0)
	for i in range(1,n+1):
		print(dis[i]) main n = int(input()) n int(input()) int input() input for i in range(n-1):
		x, y , w = map(int , input().split())
		w = w%2
		adj[x].append([y , w])
		adj[y].append([x, w])
	 i range(n-1) range n-1 n 1 x, y , w = map(int , input().split()) x map(int , input().split()) map int input().split() ().split () input split y w w = w%2 w w%2 w 2 adj[x].append([y , w]) [x].append [x] adj x append [y , w] y w adj[y].append([x, w]) [y].append [y] adj y append [x, w] x w dfs(1, 0) dfs 1 0 for i in range(1,n+1):
		print(dis[i]) i range(1,n+1) range 1 n+1 n 1 print(dis[i]) print dis[i] dis i if __name__ =="__main__":
	main() __name__ =="__main__" __name__ "__main__" main() main adj = defaultdict(list) defaultdict(list) adj dis =[0 for i in range(1000000)] [0 for i in range(1000000)] dis def dfs(u , p):
	for i , w in adj[u]:
		if i==p:
			continue
		dis[i]=dis[u]+w
		dis[i]=dis[i]%2
		dfs(i , u) def dfs(u , p):
	for i , w in adj[u]:
		if i==p:
			continue
		dis[i]=dis[u]+w
		dis[i]=dis[i]%2
		dfs(i , u) dfs def main():
	n = int(input())
	for i in range(n-1):
		x, y , w = map(int , input().split())
		w = w%2
		adj[x].append([y , w])
		adj[y].append([x, w])
	dfs(1, 0)
	for i in range(1,n+1):
		print(dis[i]) def main():
	n = int(input())
	for i in range(n-1):
		x, y , w = map(int , input().split())
		w = w%2
		adj[x].append([y , w])
		adj[y].append([x, w])
	dfs(1, 0)
	for i in range(1,n+1):
		print(dis[i]) main
# distance between two nodes is dis(root, a)+dis(root, b)-2*(dis(lca(a,b),root))
# taking mod 2 last term is eliminated 
# all nodes having dis as odd parity from root will be white color
# all nodes having dis as even parity from root will be even color
import sys
import os
sys.setrecursionlimit(1000000)
from collections import defaultdict
adj = defaultdict(list)
dis =[0 for i in range(1000000)]
def dfs(u , p):
	for i , w in adj[u]:
		if i==p:
			continue
		dis[i]=dis[u]+w
		dis[i]=dis[i]%2
		dfs(i , u)
def main():
	n = int(input())
	for i in range(n-1):
		x, y , w = map(int , input().split())
		w = w%2
		adj[x].append([y , w])
		adj[y].append([x, w])
	dfs(1, 0)
	for i in range(1,n+1):
		print(dis[i])
if __name__ =="__main__":
	main()