from collections import deque

n = int(input())

u = [0] * n
v = [0] * n
w = [0] * n

dist = [-1] * n
adj_list = [[] for _ in range(n)]

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

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

q = deque()
dist[0] = 0
q.append(0)

while len(q) > 0:
    node = q.popleft()

    for next, d in adj_list[node]:
        if dist[next] > 0:
            continue

        if dist[next] == -1 or dist[next] > dist[node] + d:
            dist[next] = dist[node] + d
            q.append(next)

for i in range(n):
    if dist[i] % 2 == 0:
        dist[i] = 0
    else:
        dist[i] = 1
    print(dist[i]) from collections import deque n = int(input()) n int(input()) int input() input u = [0] * n u [0] * n [0] 0 n v = [0] * n v [0] * n [0] 0 n w = [0] * n w [0] * n [0] 0 n dist = [-1] * n dist [-1] * n [-1] -1 n [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] adj_list = [[] for _ in range(n)] adj_list [[] for _ in range(n)] for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1

    adj_list[u].append([v, w])
    adj_list[v].append([u, w]) 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 adj_list[u].append([v, w]) [u].append [u] adj_list u append [v, w] v w adj_list[v].append([u, w]) [v].append [v] adj_list v append [u, w] u w q = deque() q deque() deque dist[0] = 0 dist[0] dist 0 0 q.append(0) q.append q append 0 while len(q) > 0:
    node = q.popleft()

    for next, d in adj_list[node]:
        if dist[next] > 0:
            continue

        if dist[next] == -1 or dist[next] > dist[node] + d:
            dist[next] = dist[node] + d
            q.append(next) len(q) > 0 len(q) len q 0 node = q.popleft() node q.popleft() q.popleft q popleft for next, d in adj_list[node]:
        if dist[next] > 0:
            continue

        if dist[next] == -1 or dist[next] > dist[node] + d:
            dist[next] = dist[node] + d
            q.append(next) next d adj_list[node] adj_list node if dist[next] > 0:
            continue

         dist[next] > 0 dist[next] dist next 0 continue if dist[next] == -1 or dist[next] > dist[node] + d:
            dist[next] = dist[node] + d
            q.append(next) dist[next] == -1 or dist[next] > dist[node] + d dist[next] == -1 dist[next] dist next -1 dist[next] > dist[node] + d dist[next] dist next dist[node] + d dist[node] dist node d dist[next] = dist[node] + d dist[next] dist next dist[node] + d dist[node] dist node d q.append(next) q.append q append next for i in range(n):
    if dist[i] % 2 == 0:
        dist[i] = 0
    else:
        dist[i] = 1
    print(dist[i]) i range(n) range n if dist[i] % 2 == 0:
        dist[i] = 0
    else:
        dist[i] = 1
     dist[i] % 2 == 0 dist[i] % 2 dist[i] dist i 2 0 dist[i] = 0 dist[i] dist i 0 dist[i] = 1 dist[i] dist i 1 print(dist[i]) print dist[i] dist i u = [0] * n [0] * n u v, w = map(int, input().split()) map(int, input().split()) v v = [0] * n [0] * n v adj_list = [[] for _ in range(n)] [[] for _ in range(n)] adj_list u, v, w = map(int, input().split()) map(int, input().split()) u w = [0] * n [0] * n w dist = [-1] * n [-1] * n dist u -= 1 1 u w = map(int, input().split()) map(int, input().split()) w n = int(input()) int(input()) n node = q.popleft() q.popleft() node q = deque() deque() q v -= 1 1 v
from collections import deque

n = int(input())

u = [0] * n
v = [0] * n
w = [0] * n

dist = [-1] * n
adj_list = [[] for _ in range(n)]

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

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

q = deque()
dist[0] = 0
q.append(0)

while len(q) > 0:
    node = q.popleft()

    for next, d in adj_list[node]:
        if dist[next] > 0:
            continue

        if dist[next] == -1 or dist[next] > dist[node] + d:
            dist[next] = dist[node] + d
            q.append(next)

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