import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
if N==1:
    print(0)
    exit()
color=[-1]*(N+1)
cost=[-1]*(N+1)
node=[list() for _ in range(N+1)]
for _ in range(N-1):
    u,v,w=mint()
    node[u].append([v,w])
    node[v].append([u,w])
color[1]=0
cost[1]=0
q=deque([1])
while q:
    u=q.popleft()
    for v,w in node[u]:
        if color[v]<0:
            cost[v]=cost[u]+w
            color[v]=cost[v]%2
            q.append(v)
lprint(color[1:]) import sys sys from sys import exit from collections import deque from copy import deepcopy from bisect import bisect_left, bisect_right, insort_left, insort_right from heapq import heapify, heappop, heappush from itertools import product, permutations, combinations, combinations_with_replacement from functools import reduce from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 INF = 10**20 INF 10**20 10 20 eps = 1.0e-20 eps 1.0e-20 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 def lcm(x,y):
    return x*y//gcd(x,y) lcm return x*y//gcd(x,y) x*y//gcd(x,y) x*y x y gcd(x,y) gcd x y x x y y def lgcd(l):
    return reduce(gcd,l) lgcd return reduce(gcd,l) reduce(gcd,l) reduce gcd l l l def llcm(l):
    return reduce(lcm,l) llcm return reduce(lcm,l) reduce(lcm,l) reduce lcm l l l def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) powmod return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) i<0 i 0 pow(n,mod-1+i,mod) pow n mod-1+i mod-1 mod 1 i mod pow(n,i,mod) pow n i mod n n i i mod=MOD mod MOD def div2(x):
    return x.bit_length() div2 return x.bit_length() x.bit_length() x.bit_length x bit_length x x def div10(x):
    return len(str(x))-(x==0) div10 return len(str(x))-(x==0) len(str(x))-(x==0) len(str(x)) len str(x) str x x==0 x 0 x x def intput():
    return int(input()) intput return int(input()) int(input()) int input() input def mint():
    return map(int,input().split()) mint return map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split def lint():
    return list(map(int,input().split())) lint return list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split def ilint():
    return int(input()), list(map(int,input().split())) ilint return int(input()), list(map(int,input().split())) return int(input()), list(map(int,input().split())) int(input()) int input() input list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1]) judge print(l[0] if x else l[1]) print l[0] if x else l[1] x l[0] l 0 l[1] l 1 x x l=['Yes', 'No'] l ['Yes', 'No'] 'Yes' 'No' def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep) lprint for x in l:
        print(x, end=sep) x l print(x, end=sep) print x end=sep end sep l l sep='\n' sep '\n' def ston(c, c0='a'):
    return ord(c)-ord(c0) ston return ord(c)-ord(c0) ord(c)-ord(c0) ord(c) ord c ord(c0) ord c0 c c c0='a' c0 'a' def ntos(x, c0='a'):
    return chr(x+ord(c0)) ntos return chr(x+ord(c0)) chr(x+ord(c0)) chr x+ord(c0) x ord(c0) ord c0 x x c0='a' c0 'a' class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l counter def __init__(self, *args):
        super().__init__(args)
     __init__ super().__init__(args) ().__init__ () super __init__ args self self *args def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
     add self.setdefault(x,0) self.setdefault self setdefault x 0 self[x] += d self[x] self x d self self x x d=1 d 1 def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l list l = [] l [] for k in self:
            l.extend([k]*self[k])
         k self l.extend([k]*self[k]) l.extend l extend [k]*self[k] [k] k self[k] self k return l l self self dict class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] comb def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
     __init__ self.l = [1] self.l self l [1] 1 self.n = n self.n self n n self.mod = mod self.mod self mod mod self self n n mod=None mod None def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] get l,n,mod = self.l, self.n, self.mod l self.l self l n self.n self n mod self.mod self mod k = n-k if k>n//2 else k k n-k if k>n//2 else k k>n//2 k n//2 n 2 n-k n k k while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
         len(l)<=k len(l) len l k i = len(l) i len(l) len l l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod) l.append l append l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod mod==None mod None l[i-1]*(n+1-i)//i l[i-1]*(n+1-i) l[i-1] l i-1 i 1 n+1-i n+1 n 1 i i (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod l[i-1]*(n+1-i)*powmod(i,-1,mod) l[i-1]*(n+1-i) l[i-1] l i-1 i 1 n+1-i n+1 n 1 i powmod(i,-1,mod) powmod i -1 mod mod return l[k] l[k] l k self self k k def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

###################################################### pf C = counter() C counter() counter p = 2 p 2 while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
     x>1 x 1 k = 0 k 0 while x%p==0:
            x //= p
            k += 1
         x%p==0 x%p x p 0 x //= p x p k += 1 k 1 if k>0:
            C.add(p,k)
         k>0 k 0 C.add(p,k) C.add C add p k p = p+2-(p==2) if p*p<x else x p p+2-(p==2) if p*p<x else x p*p<x p*p p p x p+2-(p==2) p+2 p 2 p==2 p 2 x if mode=='counter':
        return C
     mode=='counter' mode 'counter' return C C S = set([1]) S set([1]) set [1] 1 for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
     k C T = deepcopy(S) T deepcopy(S) deepcopy S for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
     x T for i in range(1,C[k]+1):
                S.add(x*(k**i))
     i range(1,C[k]+1) range 1 C[k]+1 C[k] C k 1 S.add(x*(k**i)) S.add S add x*(k**i) x k**i k i if mode=='set':
        return S
     mode=='set' mode 'set' return S S if mode=='list':
        return sorted(list(S))

###################################################### mode=='list' mode 'list' return sorted(list(S)) sorted(list(S)) sorted list(S) list S x x mode='counter' mode 'counter' N=intput() N intput() intput if N==1:
    print(0)
    exit() N==1 N 1 print(0) print 0 exit() exit color=[-1]*(N+1) color [-1]*(N+1) [-1] -1 N+1 N 1 cost=[-1]*(N+1) cost [-1]*(N+1) [-1] -1 N+1 N 1 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 node=[list() for _ in range(N+1)] node [list() for _ in range(N+1)] for _ in range(N-1):
    u,v,w=mint()
    node[u].append([v,w])
    node[v].append([u,w]) _ range(N-1) range N-1 N 1 u,v,w=mint() u mint() mint v w node[u].append([v,w]) [u].append [u] node u append [v,w] v w node[v].append([u,w]) [v].append [v] node v append [u,w] u w color[1]=0 color[1] color 1 0 cost[1]=0 cost[1] cost 1 0 q=deque([1]) q deque([1]) deque [1] 1 while q:
    u=q.popleft()
    for v,w in node[u]:
        if color[v]<0:
            cost[v]=cost[u]+w
            color[v]=cost[v]%2
            q.append(v) q u=q.popleft() u q.popleft() q.popleft q popleft for v,w in node[u]:
        if color[v]<0:
            cost[v]=cost[u]+w
            color[v]=cost[v]%2
            q.append(v) v w node[u] node u if color[v]<0:
            cost[v]=cost[u]+w
            color[v]=cost[v]%2
            q.append(v) color[v]<0 color[v] color v 0 cost[v]=cost[u]+w cost[v] cost v cost[u]+w cost[u] cost u w color[v]=cost[v]%2 color[v] color v cost[v]%2 cost[v] cost v 2 q.append(v) q.append q append v lprint(color[1:]) lprint color[1:] color 1: 1 q=deque([1]) deque([1]) q def div2(x):
    return x.bit_length() def div2(x):
    return x.bit_length() div2 def lcm(x,y):
    return x*y//gcd(x,y) def lcm(x,y):
    return x*y//gcd(x,y) lcm N=intput() intput() N def mint():
    return map(int,input().split()) def mint():
    return map(int,input().split()) mint class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k] comb u=q.popleft() q.popleft() u MOD = 10**9+7 10**9+7 MOD def ston(c, c0='a'):
    return ord(c)-ord(c0) def ston(c, c0='a'):
    return ord(c)-ord(c0) ston def intput():
    return int(input()) def intput():
    return int(input()) intput def lint():
    return list(map(int,input().split())) def lint():
    return list(map(int,input().split())) lint node=[list() for _ in range(N+1)] [list() for _ in range(N+1)] node def ntos(x, c0='a'):
    return chr(x+ord(c0)) def ntos(x, c0='a'):
    return chr(x+ord(c0)) ntos v,w=mint() mint() v def llcm(l):
    return reduce(lcm,l) def llcm(l):
    return reduce(lcm,l) llcm class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l counter cost=[-1]*(N+1) [-1]*(N+1) cost INF = 10**20 10**20 INF def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1]) def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1]) judge w=mint() mint() w eps = 1.0e-20 1.0e-20 eps def lgcd(l):
    return reduce(gcd,l) def lgcd(l):
    return reduce(gcd,l) lgcd def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

###################################################### def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

###################################################### pf def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod) powmod color=[-1]*(N+1) [-1]*(N+1) color def ilint():
    return int(input()), list(map(int,input().split())) def ilint():
    return int(input()), list(map(int,input().split())) ilint def div10(x):
    return len(str(x))-(x==0) def div10(x):
    return len(str(x))-(x==0) div10 def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep) def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep) lprint u,v,w=mint() mint() u
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
if N==1:
    print(0)
    exit()
color=[-1]*(N+1)
cost=[-1]*(N+1)
node=[list() for _ in range(N+1)]
for _ in range(N-1):
    u,v,w=mint()
    node[u].append([v,w])
    node[v].append([u,w])
color[1]=0
cost[1]=0
q=deque([1])
while q:
    u=q.popleft()
    for v,w in node[u]:
        if color[v]<0:
            cost[v]=cost[u]+w
            color[v]=cost[v]%2
            q.append(v)
lprint(color[1:])