import collections
import heapq

def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

class Dijkstra():
    
    def __init__(self):  self.e = collections.defaultdict(list)

    def add(self, u, v, d, directed = False):
        self.e[u].append([v, d])
        self.e[v].append([u, d]) # 有向グラフの場合、コメントアウト

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def Dijkstra_search(self, s):

        d = collections.defaultdict(lambda: float('inf'))
        prev = collections.defaultdict(lambda: None)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while q:
        
            k, u = heapq.heappop(q)
            if v[u]:  continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

        return d, prev

    def getDijkstraShortestPath(self, start, goal):
        _, prev = self.Dijkstra_search(start)
        shortestPath = []
        node = goal
        while node is not None:
            shortestPath.append(node)
            node = prev[node]
        return shortestPath[::-1]

graph = Dijkstra()
N = cin()
for i in range(N - 1): 
    in_ = cin()
    graph.add(in_[0] - 1, in_[1] - 1, in_[2])
min_w, prev = graph.Dijkstra_search(0)
ans = [0 for _ in range(N)]
for i in range(N):  print(min_w[i] % 2) import collections collections import heapq heapq def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_ cin in_ = list(map(int,input().split())) in_ list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split if len(in_) == 1:  return in_[0]
    else:  return in_ len(in_) == 1 len(in_) len in_ 1 class Dijkstra():
    
    def __init__(self):  self.e = collections.defaultdict(list)

    def add(self, u, v, d, directed = False):
        self.e[u].append([v, d])
        self.e[v].append([u, d]) # 有向グラフの場合、コメントアウト

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def Dijkstra_search(self, s):

        d = collections.defaultdict(lambda: float('inf'))
        prev = collections.defaultdict(lambda: None)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while q:
        
            k, u = heapq.heappop(q)
            if v[u]:  continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

        return d, prev

    def getDijkstraShortestPath(self, start, goal):
        _, prev = self.Dijkstra_search(start)
        shortestPath = []
        node = goal
        while node is not None:
            shortestPath.append(node)
            node = prev[node]
        return shortestPath[::-1] Dijkstra def __init__(self):  self.e = collections.defaultdict(list)

     __init__ self self def add(self, u, v, d, directed = False):
        self.e[u].append([v, d])
        self.e[v].append([u, d]) # 有向グラフの場合、コメントアウト

     add self.e[u].append([v, d]) self.e[u].append self.e[u] self.e self e u append [v, d] v d self.e[v].append([u, d]) self.e[v].append self.e[v] self.e self e v append [u, d] u d self self u u v v d d directed = False directed False def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

     delete _ for _ in self.e[u] if _[0] != v for _ in self.e[u] if _[0] != v _ self.e[u] self.e self e u _[0] != v _[0] _ 0 v if _[0] != v _ self.e[u] = [_ for _ in self.e[u] if _[0] != v] self.e[u] self.e self e u [_ for _ in self.e[u] if _[0] != v] _ for _ in self.e[v] if _[0] != u for _ in self.e[v] if _[0] != u _ self.e[v] self.e self e v _[0] != u _[0] _ 0 u if _[0] != u _ self.e[v] = [_ for _ in self.e[v] if _[0] != u] self.e[v] self.e self e v [_ for _ in self.e[v] if _[0] != u] self self u u v v def Dijkstra_search(self, s):

        d = collections.defaultdict(lambda: float('inf'))
        prev = collections.defaultdict(lambda: None)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while q:
        
            k, u = heapq.heappop(q)
            if v[u]:  continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

        return d, prev

     Dijkstra_search d = collections.defaultdict(lambda: float('inf')) d collections.defaultdict(lambda: float('inf')) collections.defaultdict collections defaultdict lambda: float('inf') float('inf') float 'inf' prev = collections.defaultdict(lambda: None) prev collections.defaultdict(lambda: None) collections.defaultdict collections defaultdict lambda: None None d[s] = 0 d[s] d s 0 q = [] q [] heapq.heappush(q, (0, s)) heapq.heappush heapq heappush q (0, s) 0 s v = collections.defaultdict(bool) v collections.defaultdict(bool) collections.defaultdict collections defaultdict bool while q:
        
            k, u = heapq.heappop(q)
            if v[u]:  continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

         q k, u = heapq.heappop(q) k heapq.heappop(q) heapq.heappop heapq heappop q u if v[u]:  continue
             v[u] v u v[u] = True v[u] v u True for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

         uv ud self.e[u] self.e self e u if v[uv]:  continue
                 v[uv] v uv vd = k + ud vd k + ud k ud if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

         d[uv] > vd d[uv] d uv vd d[uv] = vd d[uv] d uv vd prev[uv] = u prev[uv] prev uv u heapq.heappush(q, (vd, uv)) heapq.heappush heapq heappush q (vd, uv) vd uv return d, prev return d, prev d prev self self s s def getDijkstraShortestPath(self, start, goal):
        _, prev = self.Dijkstra_search(start)
        shortestPath = []
        node = goal
        while node is not None:
            shortestPath.append(node)
            node = prev[node]
        return shortestPath[::-1] getDijkstraShortestPath _, prev = self.Dijkstra_search(start) _ self.Dijkstra_search(start) self.Dijkstra_search self Dijkstra_search start prev shortestPath = [] shortestPath [] node = goal node goal while node is not None:
            shortestPath.append(node)
            node = prev[node]
         node is not None node None shortestPath.append(node) shortestPath.append shortestPath append node node = prev[node] node prev[node] prev node return shortestPath[::-1] shortestPath[::-1] shortestPath ::-1 -1 self self start start goal goal graph = Dijkstra() graph Dijkstra() Dijkstra N = cin() N cin() cin for i in range(N - 1): 
    in_ = cin()
    graph.add(in_[0] - 1, in_[1] - 1, in_[2]) i range(N - 1) range N - 1 N 1 in_ = cin() in_ cin() cin graph.add(in_[0] - 1, in_[1] - 1, in_[2]) graph.add graph add in_[0] - 1 in_[0] in_ 0 1 in_[1] - 1 in_[1] in_ 1 1 in_[2] in_ 2 min_w, prev = graph.Dijkstra_search(0) min_w graph.Dijkstra_search(0) graph.Dijkstra_search graph Dijkstra_search 0 prev 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 ans = [0 for _ in range(N)] ans [0 for _ in range(N)] for i in range(N):  print(min_w[i] % 2) i range(N) range N min_w, prev = graph.Dijkstra_search(0) graph.Dijkstra_search(0) min_w ans = [0 for _ in range(N)] [0 for _ in range(N)] ans graph = Dijkstra() Dijkstra() graph prev = graph.Dijkstra_search(0) graph.Dijkstra_search(0) prev def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_ def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_ cin in_ = cin() cin() in_ class Dijkstra():
    
    def __init__(self):  self.e = collections.defaultdict(list)

    def add(self, u, v, d, directed = False):
        self.e[u].append([v, d])
        self.e[v].append([u, d]) # 有向グラフの場合、コメントアウト

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def Dijkstra_search(self, s):

        d = collections.defaultdict(lambda: float('inf'))
        prev = collections.defaultdict(lambda: None)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while q:
        
            k, u = heapq.heappop(q)
            if v[u]:  continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

        return d, prev

    def getDijkstraShortestPath(self, start, goal):
        _, prev = self.Dijkstra_search(start)
        shortestPath = []
        node = goal
        while node is not None:
            shortestPath.append(node)
            node = prev[node]
        return shortestPath[::-1] class Dijkstra():
    
    def __init__(self):  self.e = collections.defaultdict(list)

    def add(self, u, v, d, directed = False):
        self.e[u].append([v, d])
        self.e[v].append([u, d]) # 有向グラフの場合、コメントアウト

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def Dijkstra_search(self, s):

        d = collections.defaultdict(lambda: float('inf'))
        prev = collections.defaultdict(lambda: None)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while q:
        
            k, u = heapq.heappop(q)
            if v[u]:  continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

        return d, prev

    def getDijkstraShortestPath(self, start, goal):
        _, prev = self.Dijkstra_search(start)
        shortestPath = []
        node = goal
        while node is not None:
            shortestPath.append(node)
            node = prev[node]
        return shortestPath[::-1] Dijkstra N = cin() cin() N
import collections
import heapq

def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

class Dijkstra():
    
    def __init__(self):  self.e = collections.defaultdict(list)

    def add(self, u, v, d, directed = False):
        self.e[u].append([v, d])
        self.e[v].append([u, d]) # 有向グラフの場合、コメントアウト

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def Dijkstra_search(self, s):

        d = collections.defaultdict(lambda: float('inf'))
        prev = collections.defaultdict(lambda: None)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while q:
        
            k, u = heapq.heappop(q)
            if v[u]:  continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:  continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

        return d, prev

    def getDijkstraShortestPath(self, start, goal):
        _, prev = self.Dijkstra_search(start)
        shortestPath = []
        node = goal
        while node is not None:
            shortestPath.append(node)
            node = prev[node]
        return shortestPath[::-1]

graph = Dijkstra()
N = cin()
for i in range(N - 1): 
    in_ = cin()
    graph.add(in_[0] - 1, in_[1] - 1, in_[2])
min_w, prev = graph.Dijkstra_search(0)
ans = [0 for _ in range(N)]
for i in range(N):  print(min_w[i] % 2)