import heapq
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])

def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        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]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

Path_from_0 = dijkstra_heap(0)
for i in range(n):
    print(Path_from_0[i] % 2) import heapq heapq 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 def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        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]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d dijkstra_heap d = [float("inf")] * n d [float("inf")] * n [float("inf")] float("inf") float "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 [] for e in edge[s]:
        heapq.heappush(edgelist,e)
     e edge[s] edge s heapq.heappush(edgelist,e) heapq.heappush heapq heappush edgelist e while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        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]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
     len(edgelist) len edgelist minedge = heapq.heappop(edgelist) minedge heapq.heappop(edgelist) heapq.heappop heapq heappop edgelist 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]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
     e edge[v] edge v if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
     used[e[1]] used e[1] e 1 heapq.heappush(edgelist,[e[0]+d[v],e[1]]) heapq.heappush heapq heappush edgelist [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 Path_from_0 = dijkstra_heap(0) Path_from_0 dijkstra_heap(0) dijkstra_heap 0 for i in range(n):
    print(Path_from_0[i] % 2) i range(n) range n print(Path_from_0[i] % 2) print Path_from_0[i] % 2 Path_from_0[i] Path_from_0 i 2 v, w = map(int, input().split()) map(int, input().split()) v u, v, w = map(int, input().split()) map(int, input().split()) u v -= 1 1 v edge = [[] for i in range(n)] [[] for i in range(n)] edge def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        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]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        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]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d dijkstra_heap w = map(int, input().split()) map(int, input().split()) w n = int(input()) int(input()) n u -= 1 1 u Path_from_0 = dijkstra_heap(0) dijkstra_heap(0) Path_from_0
import heapq
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])

def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        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]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

Path_from_0 = dijkstra_heap(0)
for i in range(n):
    print(Path_from_0[i] % 2)