from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def bfs():
    dist = [-1]*n
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
    return dist

n = INT()
g = [[] for i in range(n)]
for i in range(n-1):
    x, y, z = MAP()
    g[x-1].append([y-1, z])
    g[y-1].append([x-1, z])
for k in bfs():
    print(0 if k%2 == 0 else 1) from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heapify,heappop,heappush from queue import Queue,LifoQueue,PriorityQueue from copy import deepcopy from time import time from functools import reduce import string string import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 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()) LIST def bfs():
    dist = [-1]*n
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
    return dist bfs dist = [-1]*n dist [-1]*n [-1] -1 n que = deque([0]) que deque([0]) deque [0] 0 dist[0] = 0 dist[0] dist 0 0 while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
     que v = que.popleft() v que.popleft() que.popleft que popleft d = dist[v] d dist[v] dist v for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
     w g[v] g v if dist[w[0]] > -1:
                continue
             dist[w[0]] > -1 dist[w[0]] dist w[0] w 0 -1 continue dist[w[0]] = d + w[1] dist[w[0]] dist w[0] w 0 d + w[1] d w[1] w 1 que.append(w[0]) que.append que append w[0] w 0 return dist dist n = INT() n INT() INT [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] g = [[] for i in range(n)] g [[] for i in range(n)] for i in range(n-1):
    x, y, z = MAP()
    g[x-1].append([y-1, z])
    g[y-1].append([x-1, z]) i range(n-1) range n-1 n 1 x, y, z = MAP() x MAP() MAP y z g[x-1].append([y-1, z]) [x-1].append [x-1] g x-1 x 1 append [y-1, z] y-1 y 1 z g[y-1].append([x-1, z]) [y-1].append [y-1] g y-1 y 1 append [x-1, z] x-1 x 1 z for k in bfs():
    print(0 if k%2 == 0 else 1) k bfs() bfs print(0 if k%2 == 0 else 1) print 0 if k%2 == 0 else 1 k%2 == 0 k%2 k 2 0 0 1 def LIST()  : return list(MAP()) def LIST()  : return list(MAP()) LIST def bfs():
    dist = [-1]*n
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
    return dist def bfs():
    dist = [-1]*n
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
    return dist bfs g = [[] for i in range(n)] [[] for i in range(n)] g n = INT() INT() n def INT()   : return int(input()) def INT()   : return int(input()) INT z = MAP() MAP() z y, z = MAP() MAP() y def input() : return sys.stdin.readline().strip() def input() : return sys.stdin.readline().strip() input def MAP()   : return map(int,input().split()) def MAP()   : return map(int,input().split()) MAP x, y, z = MAP() MAP() x
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def bfs():
    dist = [-1]*n
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w[0]] > -1:
                continue
            dist[w[0]] = d + w[1]
            que.append(w[0])
    return dist

n = INT()
g = [[] for i in range(n)]
for i in range(n-1):
    x, y, z = MAP()
    g[x-1].append([y-1, z])
    g[y-1].append([x-1, z])
for k in bfs():
    print(0 if k%2 == 0 else 1)