import sys
from collections import deque
input = sys.stdin.readline
N = int(input())

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

q = deque()
q.append((0, 0))
color = {}
while q:
    node, dist = q.popleft()
    if node in color:
        continue
    if dist % 2 == 0:
        color[node] = 0
    else:
        color[node] = 1
    for n_node, n_dist in edges[node]:
        q.append((n_node, dist+n_dist))

for i in range(N):
    print(color[i]) import sys sys from collections import deque input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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) [] edges = [[] for _ in range(N)] edges [[] for _ in range(N)] for _ in range(N-1):
    u, v, w = map(int, input().split())
    edges[u-1].append((v-1, w))
    edges[v-1].append((u-1, w)) _ 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 edges[u-1].append((v-1, w)) [u-1].append [u-1] edges u-1 u 1 append (v-1, w) v-1 v 1 w edges[v-1].append((u-1, w)) [v-1].append [v-1] edges v-1 v 1 append (u-1, w) u-1 u 1 w q = deque() q deque() deque q.append((0, 0)) q.append q append (0, 0) 0 0 color = {} color {} while q:
    node, dist = q.popleft()
    if node in color:
        continue
    if dist % 2 == 0:
        color[node] = 0
    else:
        color[node] = 1
    for n_node, n_dist in edges[node]:
        q.append((n_node, dist+n_dist)) q node, dist = q.popleft() node q.popleft() q.popleft q popleft dist if node in color:
        continue
     node in color node color continue if dist % 2 == 0:
        color[node] = 0
    else:
        color[node] = 1
     dist % 2 == 0 dist % 2 dist 2 0 color[node] = 0 color[node] color node 0 color[node] = 1 color[node] color node 1 for n_node, n_dist in edges[node]:
        q.append((n_node, dist+n_dist)) n_node n_dist edges[node] edges node q.append((n_node, dist+n_dist)) q.append q append (n_node, dist+n_dist) n_node dist+n_dist dist n_dist for i in range(N):
    print(color[i]) i range(N) range N print(color[i]) print color[i] color i w = map(int, input().split()) map(int, input().split()) w v, w = map(int, input().split()) map(int, input().split()) v q = deque() deque() q dist = q.popleft() q.popleft() dist N = int(input()) int(input()) N u, v, w = map(int, input().split()) map(int, input().split()) u color = {} {} color edges = [[] for _ in range(N)] [[] for _ in range(N)] edges input = sys.stdin.readline sys.stdin.readline input node, dist = q.popleft() q.popleft() node
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())

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

q = deque()
q.append((0, 0))
color = {}
while q:
    node, dist = q.popleft()
    if node in color:
        continue
    if dist % 2 == 0:
        color[node] = 0
    else:
        color[node] = 1
    for n_node, n_dist in edges[node]:
        q.append((n_node, dist+n_dist))

for i in range(N):
    print(color[i])