import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    edge[v - 1].append([w, u - 1])
    edge[u - 1].append([w, v - 1])

# O(ElogV)
import heapq
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d

d = dijkstra(0)
ans = [0]*n

for i in range(n):
    if d[i] % 2 == 1:
        ans[i] = 1

for i in ans:
    print(i) import sys sys input = lambda : sys.stdin.readline().rstrip() input lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip n = int(input()) n int(input()) int input() input [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] edge = [[] for _ in range(n)] edge [[] for _ in range(n)] for _ in range(n - 1):
    u, v, w = map(int, input().split())
    edge[v - 1].append([w, u - 1])
    edge[u - 1].append([w, v - 1])

# O(ElogV) _ 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 edge[v - 1].append([w, u - 1]) [v - 1].append [v - 1] edge v - 1 v 1 append [w, u - 1] w u - 1 u 1 edge[u - 1].append([w, v - 1]) [u - 1].append [u - 1] edge u - 1 u 1 append [w, v - 1] w v - 1 v 1 import heapq heapq def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d dijkstra d = [float('inf')]*n d [float('inf')]*n [float('inf')] float('inf') float 'inf' n d[s] = 0 d[s] d s 0 used = [False]*n used [False]*n [False] False n used[s] = True used[s] used s True que = [] que [] for e in edge[s]:
        heapq.heappush(que, e)
     e edge[s] edge s heapq.heappush(que, e) heapq.heappush heapq heappush que e while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
     que minedge = heapq.heappop(que) minedge heapq.heappop(que) heapq.heappop heapq heappop que if used[minedge[1]]:
            continue
         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] = True used[v] used v True for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
     e edge[v] edge v if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
     not used[e[1]] used[e[1]] used e[1] e 1 heapq.heappush(que, [e[0] + d[v], e[1]]) heapq.heappush heapq heappush que [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 d = dijkstra(0) d dijkstra(0) dijkstra 0 ans = [0]*n ans [0]*n [0] 0 n for i in range(n):
    if d[i] % 2 == 1:
        ans[i] = 1 i range(n) range n if d[i] % 2 == 1:
        ans[i] = 1 d[i] % 2 == 1 d[i] % 2 d[i] d i 2 1 ans[i] = 1 ans[i] ans i 1 for i in ans:
    print(i) i ans print(i) print i input = lambda : sys.stdin.readline().rstrip() lambda : sys.stdin.readline().rstrip() input def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d dijkstra u, v, w = map(int, input().split()) map(int, input().split()) u w = map(int, input().split()) map(int, input().split()) w edge = [[] for _ in range(n)] [[] for _ in range(n)] edge n = int(input()) int(input()) n d = dijkstra(0) dijkstra(0) d ans = [0]*n [0]*n ans v, w = map(int, input().split()) map(int, input().split()) v
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    edge[v - 1].append([w, u - 1])
    edge[u - 1].append([w, v - 1])

# O(ElogV)
import heapq
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d

d = dijkstra(0)
ans = [0]*n

for i in range(n):
    if d[i] % 2 == 1:
        ans[i] = 1

for i in ans:
    print(i)