import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
uvw = [LIST() for _ in range(N-1)]

graph = defaultdict(list)

for u, v, w in uvw:
	graph[u-1].append((v-1, w))
	graph[v-1].append((u-1, w))

#print(graph)

color = [0]*N
color[0] = 1

def DFS(node):
	for x, w in graph[node]:
		if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x)

DFS(0)

for x in color:
	if x == 1:
		print(0)
	elif x == -1:
		print(1)
	else:
		print("HOGE")



 import sys, re sys re from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees from collections import deque, defaultdict, Counter from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop, heapify from functools import reduce def input(): return sys.stdin.readline().strip() input def INT(): return int(input()) INT def MAP(): return map(int, input().split()) MAP def LIST(): return list(map(int, input().split())) LIST MAP() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) MAP() MAP def ZIP(n): return zip(*(MAP() for _ in range(n))) ZIP n n sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = float('inf') INF float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 N = INT() N INT() INT LIST() for _ in range(N-1) for _ in range(N-1) _ range(N-1) range N-1 N 1 for _ in range(N-1) LIST() LIST uvw = [LIST() for _ in range(N-1)] uvw [LIST() for _ in range(N-1)] graph = defaultdict(list) graph defaultdict(list) defaultdict list for u, v, w in uvw:
	graph[u-1].append((v-1, w))
	graph[v-1].append((u-1, w))

#print(graph) u v w uvw graph[u-1].append((v-1, w)) [u-1].append [u-1] graph u-1 u 1 append (v-1, w) v-1 v 1 w graph[v-1].append((u-1, w)) [v-1].append [v-1] graph v-1 v 1 append (u-1, w) u-1 u 1 w color = [0]*N color [0]*N [0] 0 N color[0] = 1 color[0] color 0 1 def DFS(node):
	for x, w in graph[node]:
		if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x) DFS for x, w in graph[node]:
		if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x) x w graph[node] graph node if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x) not color[x] color[x] color x if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			 w%2 == 0 w%2 w 2 0 color[x] = color[node] color[x] color x color[node] color node color[x] = color[node]*(-1) color[x] color x color[node]*(-1) color[node] color node -1 DFS(x) DFS x node node DFS(0) DFS 0 for x in color:
	if x == 1:
		print(0)
	elif x == -1:
		print(1)
	else:
		print("HOGE") x color if x == 1:
		print(0)
	elif x == -1:
		print(1)
	else:
		print("HOGE") x == 1 x 1 print(0) print 0 elif x == -1:
		print(1)
	 x == -1 x -1 print(1) print 1 print("HOGE") print "HOGE" def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input uvw = [LIST() for _ in range(N-1)] [LIST() for _ in range(N-1)] uvw N = INT() INT() N def ZIP(n): return zip(*(MAP() for _ in range(n))) def ZIP(n): return zip(*(MAP() for _ in range(n))) ZIP def INT(): return int(input()) def INT(): return int(input()) INT mod = 10 ** 9 + 7 10 ** 9 + 7 mod color = [0]*N [0]*N color def MAP(): return map(int, input().split()) def MAP(): return map(int, input().split()) MAP def LIST(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) LIST INF = float('inf') float('inf') INF graph = defaultdict(list) defaultdict(list) graph def DFS(node):
	for x, w in graph[node]:
		if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x) def DFS(node):
	for x, w in graph[node]:
		if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x) DFS
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
uvw = [LIST() for _ in range(N-1)]

graph = defaultdict(list)

for u, v, w in uvw:
	graph[u-1].append((v-1, w))
	graph[v-1].append((u-1, w))

#print(graph)

color = [0]*N
color[0] = 1

def DFS(node):
	for x, w in graph[node]:
		if not color[x]:
			if w%2 == 0:
				color[x] = color[node] 
			else:
				color[x] = color[node]*(-1)
			DFS(x)

DFS(0)

for x in color:
	if x == 1:
		print(0)
	elif x == -1:
		print(1)
	else:
		print("HOGE")




