# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=MI()
    u-=1
    v-=1
    tree[u].append([v,w])
    tree[v].append([u,w])
q=deque([[0,0]])
al=[-1 for i in range(n)]
al[0]=0
col=[0 for i in range(n)]
while q:
    a,b=q.popleft()
    #print(a,b)
    for x,y in tree[a]:
        if (b+y)%2==1:
            col[x]=1
            if al[x]==-1:
                q.append([x,1])
                al[x]=0
        else:
            if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col)
for i in range(n):
    print(str(col[i]))

    
     import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input def LI2(): return [int(input()) for i in range(n)] LI2 [LI()]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [LI()] LI() LI def MXI(): return [[LI()]for i in range(n)] MXI def SI(): return input().rstrip() SI def printns(x): print('\n'.join(x)) printns x x def printni(x): print('\n'.join(list(map(str,x)))) printni x x inf = 10**17 inf 10**17 10 17 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 n=I() n I() I [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] tree=[[] for i in range(n)] tree [[] for i in range(n)] for i in range(n-1):
    u,v,w=MI()
    u-=1
    v-=1
    tree[u].append([v,w])
    tree[v].append([u,w]) i range(n-1) range n-1 n 1 u,v,w=MI() u MI() MI v w u-=1 u 1 v-=1 v 1 tree[u].append([v,w]) [u].append [u] tree u append [v,w] v w tree[v].append([u,w]) [v].append [v] tree v append [u,w] u w q=deque([[0,0]]) q deque([[0,0]]) deque [[0,0]] [0,0] 0 0 -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 al=[-1 for i in range(n)] al [-1 for i in range(n)] al[0]=0 al[0] al 0 0 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 col=[0 for i in range(n)] col [0 for i in range(n)] while q:
    a,b=q.popleft()
    #print(a,b)
    for x,y in tree[a]:
        if (b+y)%2==1:
            col[x]=1
            if al[x]==-1:
                q.append([x,1])
                al[x]=0
        else:
            if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col) q a,b=q.popleft() a q.popleft() q.popleft q popleft b for x,y in tree[a]:
        if (b+y)%2==1:
            col[x]=1
            if al[x]==-1:
                q.append([x,1])
                al[x]=0
        else:
            if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col) x y tree[a] tree a if (b+y)%2==1:
            col[x]=1
            if al[x]==-1:
                q.append([x,1])
                al[x]=0
        else:
            if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col) (b+y)%2==1 (b+y)%2 b+y b y 2 1 col[x]=1 col[x] col x 1 if al[x]==-1:
                q.append([x,1])
                al[x]=0
         al[x]==-1 al[x] al x -1 q.append([x,1]) q.append q append [x,1] x 1 al[x]=0 al[x] al x 0 if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col) al[x]==-1 al[x] al x -1 q.append([x,0]) q.append q append [x,0] x 0 al[x]=0 al[x] al x 0 for i in range(n):
    print(str(col[i]))

    
     i range(n) range n print(str(col[i])) print str(col[i]) str col[i] col i w=MI() MI() w q=deque([[0,0]]) deque([[0,0]]) q col=[0 for i in range(n)] [0 for i in range(n)] col def MXI(): return [[LI()]for i in range(n)] def MXI(): return [[LI()]for i in range(n)] MXI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI a,b=q.popleft() q.popleft() a def LI2(): return [int(input()) for i in range(n)] def LI2(): return [int(input()) for i in range(n)] LI2 al=[-1 for i in range(n)] [-1 for i in range(n)] al def printns(x): print('\n'.join(x)) def printns(x): print('\n'.join(x)) printns u-=1 1 u def SI(): return input().rstrip() def SI(): return input().rstrip() SI def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def printni(x): print('\n'.join(list(map(str,x)))) def printni(x): print('\n'.join(list(map(str,x)))) printni n=I() I() n tree=[[] for i in range(n)] [[] for i in range(n)] tree mod = 10**9 + 7 10**9 + 7 mod b=q.popleft() q.popleft() b u,v,w=MI() MI() u input = sys.stdin.readline sys.stdin.readline input v,w=MI() MI() v inf = 10**17 10**17 inf v-=1 1 v def I(): return int(input()) def I(): return int(input()) I
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
tree=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=MI()
    u-=1
    v-=1
    tree[u].append([v,w])
    tree[v].append([u,w])
q=deque([[0,0]])
al=[-1 for i in range(n)]
al[0]=0
col=[0 for i in range(n)]
while q:
    a,b=q.popleft()
    #print(a,b)
    for x,y in tree[a]:
        if (b+y)%2==1:
            col[x]=1
            if al[x]==-1:
                q.append([x,1])
                al[x]=0
        else:
            if al[x]==-1:
                q.append([x,0])
                al[x]=0
#print(col)
for i in range(n):
    print(str(col[i]))

    
    
