from collections import deque

N = int(input())
dist = {}
graph = [[] for i in range(N)]

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


q = deque()
q.append(0)

color = [-1] * N
color[0] = 0

while q:
    now = q.popleft()

    for adj in graph[now]:
        if color[adj] == -1:
            if now < adj:
                color[adj] = color[now] + dist[(now, adj)]
            else:
                color[adj] = color[now] + dist[(adj, now)]

            q.append(adj)


for i in range(N):
    print(color[i] % 2) from collections import deque N = int(input()) N int(input()) int input() input dist = {} dist {} [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] graph = [[] for i in range(N)] graph [[] for i in range(N)] for i in range(1, N):
    u, v, w = map(int, input().split())
    graph[u-1].append(v-1)
    graph[v-1].append(u-1)
    dist[(u-1, v-1)] = w i range(1, N) range 1 N u, v, w = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v w graph[u-1].append(v-1) [u-1].append [u-1] graph u-1 u 1 append v-1 v 1 graph[v-1].append(u-1) [v-1].append [v-1] graph v-1 v 1 append u-1 u 1 dist[(u-1, v-1)] = w dist[(u-1, v-1)] dist (u-1, v-1) u-1 u 1 v-1 v 1 w q = deque() q deque() deque q.append(0) q.append q append 0 color = [-1] * N color [-1] * N [-1] -1 N color[0] = 0 color[0] color 0 0 while q:
    now = q.popleft()

    for adj in graph[now]:
        if color[adj] == -1:
            if now < adj:
                color[adj] = color[now] + dist[(now, adj)]
            else:
                color[adj] = color[now] + dist[(adj, now)]

            q.append(adj) q now = q.popleft() now q.popleft() q.popleft q popleft for adj in graph[now]:
        if color[adj] == -1:
            if now < adj:
                color[adj] = color[now] + dist[(now, adj)]
            else:
                color[adj] = color[now] + dist[(adj, now)]

            q.append(adj) adj graph[now] graph now if color[adj] == -1:
            if now < adj:
                color[adj] = color[now] + dist[(now, adj)]
            else:
                color[adj] = color[now] + dist[(adj, now)]

            q.append(adj) color[adj] == -1 color[adj] color adj -1 if now < adj:
                color[adj] = color[now] + dist[(now, adj)]
            else:
                color[adj] = color[now] + dist[(adj, now)]

             now < adj now adj color[adj] = color[now] + dist[(now, adj)] color[adj] color adj color[now] + dist[(now, adj)] color[now] color now dist[(now, adj)] dist (now, adj) now adj color[adj] = color[now] + dist[(adj, now)] color[adj] color adj color[now] + dist[(adj, now)] color[now] color now dist[(adj, now)] dist (adj, now) adj now q.append(adj) q.append q append adj for i in range(N):
    print(color[i] % 2) i range(N) range N print(color[i] % 2) print color[i] % 2 color[i] color i 2 graph = [[] for i in range(N)] [[] for i in range(N)] graph q = deque() deque() q N = int(input()) int(input()) N now = q.popleft() q.popleft() now w = map(int, input().split()) map(int, input().split()) w dist = {} {} dist color = [-1] * N [-1] * N color u, v, w = map(int, input().split()) map(int, input().split()) u v, w = map(int, input().split()) map(int, input().split()) v
from collections import deque

N = int(input())
dist = {}
graph = [[] for i in range(N)]

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


q = deque()
q.append(0)

color = [-1] * N
color[0] = 0

while q:
    now = q.popleft()

    for adj in graph[now]:
        if color[adj] == -1:
            if now < adj:
                color[adj] = color[now] + dist[(now, adj)]
            else:
                color[adj] = color[now] + dist[(adj, now)]

            q.append(adj)


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