import sys
INF = 10**18
import sys
from heapq import heapify,heappop,heappush,heappushpop


class PriorityQueue:
    
    #初期化
    def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    #値の追加
    def push(self,item):
        heappush(self.heap,item)
    
    #値の取り出し
    def pop(self):
        return heappop(self.heap)
    
    #値を追加して取り出し
    def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    #データ構造の中身を見る
    def __call__(self):
        return self.heap
    
    #heapの長さ
    def __len__(self):
        return len(self.heap)

def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [INF] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    q = PriorityQueue(edgelist)
    for e in edge[s]:
        q.push(e)
    while len(edgelist):
        minedge = q.pop()
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
    return d

if __name__ == "__main__":
    n = int(input())
    edge = [[] for i in range(n)]
    for i in range(n-1):
        u,v,w = map(int,input().split())
        u-=1
        v-=1
        edge[u].append([w,v])
        edge[v].append([w,u])
    ans = dijkstra(0)
    c_ans = [0]*n
    for i in range(n):
        if ans[i]%2 == 0:
            c_ans[i] = 0
        else:
            c_ans[i] = 1
    for i in range(n):
        print(c_ans[i]) import sys sys INF = 10**18 INF 10**18 10 18 import sys sys from heapq import heapify,heappop,heappush,heappushpop class PriorityQueue:
    
    #初期化
    def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    #値の追加
    def push(self,item):
        heappush(self.heap,item)
    
    #値の取り出し
    def pop(self):
        return heappop(self.heap)
    
    #値を追加して取り出し
    def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    #データ構造の中身を見る
    def __call__(self):
        return self.heap
    
    #heapの長さ
    def __len__(self):
        return len(self.heap) PriorityQueue def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    #値の追加
     __init__ self.heap = heap self.heap self heap heap heapify(self.heap) heapify self.heap self heap self self heap heap def push(self,item):
        heappush(self.heap,item)
    
    #値の取り出し
     push heappush(self.heap,item) heappush self.heap self heap item self self item item def pop(self):
        return heappop(self.heap)
    
    #値を追加して取り出し
     pop return heappop(self.heap) heappop(self.heap) heappop self.heap self heap self self def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    #データ構造の中身を見る
     pushpop return heappushpop(self.heap,item) heappushpop(self.heap,item) heappushpop self.heap self heap item self self item item def __call__(self):
        return self.heap
    
    #heapの長さ
     __call__ return self.heap self.heap self heap self self def __len__(self):
        return len(self.heap) __len__ return len(self.heap) len(self.heap) len self.heap self heap self self def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [INF] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    q = PriorityQueue(edgelist)
    for e in edge[s]:
        q.push(e)
    while len(edgelist):
        minedge = q.pop()
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
    return d dijkstra d = [INF] * n d [INF] * n [INF] INF n used = [True] * n used [True] * n [True] True n d[s] = 0 d[s] d s 0 used[s] = False used[s] used s False edgelist = [] edgelist [] q = PriorityQueue(edgelist) q PriorityQueue(edgelist) PriorityQueue edgelist for e in edge[s]:
        q.push(e)
     e edge[s] edge s q.push(e) q.push q push e while len(edgelist):
        minedge = q.pop()
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
     len(edgelist) len edgelist minedge = q.pop() minedge q.pop() q.pop q pop if not used[minedge[1]]:
            continue
         not used[minedge[1]] used[minedge[1]] used minedge[1] minedge 1 continue v = minedge[1] v minedge[1] minedge 1 d[v] = minedge[0] d[v] d v minedge[0] minedge 0 used[v] = False used[v] used v False for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
     e edge[v] edge v if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
     used[e[1]] used e[1] e 1 q.push([e[0]+d[v],e[1]]) q.push q push [e[0]+d[v],e[1]] e[0]+d[v] e[0] e 0 d[v] d v e[1] e 1 return d d s s if __name__ == "__main__":
    n = int(input())
    edge = [[] for i in range(n)]
    for i in range(n-1):
        u,v,w = map(int,input().split())
        u-=1
        v-=1
        edge[u].append([w,v])
        edge[v].append([w,u])
    ans = dijkstra(0)
    c_ans = [0]*n
    for i in range(n):
        if ans[i]%2 == 0:
            c_ans[i] = 0
        else:
            c_ans[i] = 1
    for i in range(n):
        print(c_ans[i]) __name__ == "__main__" __name__ "__main__" n = int(input()) n int(input()) int input() input [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] edge = [[] for i in range(n)] edge [[] for i in range(n)] for i in range(n-1):
        u,v,w = map(int,input().split())
        u-=1
        v-=1
        edge[u].append([w,v])
        edge[v].append([w,u])
     i range(n-1) range n-1 n 1 u,v,w = map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v w u-=1 u 1 v-=1 v 1 edge[u].append([w,v]) [u].append [u] edge u append [w,v] w v edge[v].append([w,u]) [v].append [v] edge v append [w,u] w u ans = dijkstra(0) ans dijkstra(0) dijkstra 0 c_ans = [0]*n c_ans [0]*n [0] 0 n for i in range(n):
        if ans[i]%2 == 0:
            c_ans[i] = 0
        else:
            c_ans[i] = 1
     i range(n) range n if ans[i]%2 == 0:
            c_ans[i] = 0
        else:
            c_ans[i] = 1
     ans[i]%2 == 0 ans[i]%2 ans[i] ans i 2 0 c_ans[i] = 0 c_ans[i] c_ans i 0 c_ans[i] = 1 c_ans[i] c_ans i 1 for i in range(n):
        print(c_ans[i]) i range(n) range n print(c_ans[i]) print c_ans[i] c_ans i c_ans = [0]*n [0]*n c_ans class PriorityQueue:
    
    #初期化
    def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    #値の追加
    def push(self,item):
        heappush(self.heap,item)
    
    #値の取り出し
    def pop(self):
        return heappop(self.heap)
    
    #値を追加して取り出し
    def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    #データ構造の中身を見る
    def __call__(self):
        return self.heap
    
    #heapの長さ
    def __len__(self):
        return len(self.heap) class PriorityQueue:
    
    #初期化
    def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    #値の追加
    def push(self,item):
        heappush(self.heap,item)
    
    #値の取り出し
    def pop(self):
        return heappop(self.heap)
    
    #値を追加して取り出し
    def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    #データ構造の中身を見る
    def __call__(self):
        return self.heap
    
    #heapの長さ
    def __len__(self):
        return len(self.heap) PriorityQueue n = int(input()) int(input()) n v-=1 1 v v,w = map(int,input().split()) map(int,input().split()) v u-=1 1 u u,v,w = map(int,input().split()) map(int,input().split()) u w = map(int,input().split()) map(int,input().split()) w INF = 10**18 10**18 INF def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [INF] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    q = PriorityQueue(edgelist)
    for e in edge[s]:
        q.push(e)
    while len(edgelist):
        minedge = q.pop()
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
    return d def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [INF] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    q = PriorityQueue(edgelist)
    for e in edge[s]:
        q.push(e)
    while len(edgelist):
        minedge = q.pop()
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
    return d dijkstra edge = [[] for i in range(n)] [[] for i in range(n)] edge ans = dijkstra(0) dijkstra(0) ans
import sys
INF = 10**18
import sys
from heapq import heapify,heappop,heappush,heappushpop


class PriorityQueue:
    
    #初期化
    def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    #値の追加
    def push(self,item):
        heappush(self.heap,item)
    
    #値の取り出し
    def pop(self):
        return heappop(self.heap)
    
    #値を追加して取り出し
    def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    #データ構造の中身を見る
    def __call__(self):
        return self.heap
    
    #heapの長さ
    def __len__(self):
        return len(self.heap)

def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [INF] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    q = PriorityQueue(edgelist)
    for e in edge[s]:
        q.push(e)
    while len(edgelist):
        minedge = q.pop()
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
    return d

if __name__ == "__main__":
    n = int(input())
    edge = [[] for i in range(n)]
    for i in range(n-1):
        u,v,w = map(int,input().split())
        u-=1
        v-=1
        edge[u].append([w,v])
        edge[v].append([w,u])
    ans = dijkstra(0)
    c_ans = [0]*n
    for i in range(n):
        if ans[i]%2 == 0:
            c_ans[i] = 0
        else:
            c_ans[i] = 1
    for i in range(n):
        print(c_ans[i])