N = int(input())
g = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1; v -= 1

    g[u].append((w, v))
    g[v].append((w, u))

from heapq import heappush, heappop, heapify
INF = float('inf')

dist = [INF] * N
visited = [False] * N

q = g[0]
heapify(q)
dist[0] = 0
visited[0] = True

while q:
    c, v = heappop(q)

    if visited[v]: continue
    visited[v] = True
    dist[v] = c

    for w, u in g[v]:
        if visited[u]: continue
        heappush(q, (c+w, u))

for i in range(N):
    if dist[i] % 2: print(0)
    else: print(1) 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) [] g = [[] for i in range(N)] g [[] for i in range(N)] for i in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1; v -= 1

    g[u].append((w, v))
    g[v].append((w, u)) i range(N-1) range N-1 N 1 u, v, w = list(map(int, input().split())) u list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split v w u -= 1 u 1 v -= 1 v 1 g[u].append((w, v)) [u].append [u] g u append (w, v) w v g[v].append((w, u)) [v].append [v] g v append (w, u) w u from heapq import heappush, heappop, heapify INF = float('inf') INF float('inf') float 'inf' dist = [INF] * N dist [INF] * N [INF] INF N visited = [False] * N visited [False] * N [False] False N q = g[0] q g[0] g 0 heapify(q) heapify q dist[0] = 0 dist[0] dist 0 0 visited[0] = True visited[0] visited 0 True while q:
    c, v = heappop(q)

    if visited[v]: continue
    visited[v] = True
    dist[v] = c

    for w, u in g[v]:
        if visited[u]: continue
        heappush(q, (c+w, u)) q c, v = heappop(q) c heappop(q) heappop q v if visited[v]: continue
     visited[v] visited v visited[v] = True visited[v] visited v True dist[v] = c dist[v] dist v c for w, u in g[v]:
        if visited[u]: continue
        heappush(q, (c+w, u)) w u g[v] g v if visited[u]: continue
         visited[u] visited u heappush(q, (c+w, u)) heappush q (c+w, u) c+w c w u for i in range(N):
    if dist[i] % 2: print(0)
    else: print(1) i range(N) range N if dist[i] % 2: print(0)
    else: print(1) dist[i] % 2 dist[i] dist i 2 v, w = list(map(int, input().split())) list(map(int, input().split())) v visited = [False] * N [False] * N visited INF = float('inf') float('inf') INF v -= 1 1 v N = int(input()) int(input()) N u -= 1 1 u c, v = heappop(q) heappop(q) c dist = [INF] * N [INF] * N dist q = g[0] g[0] q v = heappop(q) heappop(q) v g = [[] for i in range(N)] [[] for i in range(N)] g u, v, w = list(map(int, input().split())) list(map(int, input().split())) u w = list(map(int, input().split())) list(map(int, input().split())) w
N = int(input())
g = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1; v -= 1

    g[u].append((w, v))
    g[v].append((w, u))

from heapq import heappush, heappop, heapify
INF = float('inf')

dist = [INF] * N
visited = [False] * N

q = g[0]
heapify(q)
dist[0] = 0
visited[0] = True

while q:
    c, v = heappop(q)

    if visited[v]: continue
    visited[v] = True
    dist[v] = c

    for w, u in g[v]:
        if visited[u]: continue
        heappush(q, (c+w, u))

for i in range(N):
    if dist[i] % 2: print(0)
    else: print(1)