from collections import deque



N = int(eval(input()))

dist = {}

graph = [[] for i in range(N)]



for i in range(1, N):

    u, v, w = list(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))

import sys

sys.setrecursionlimit(10**8)

N = int(eval(input()))

graph = [[] for _ in range(N)]



for i in range(1, N):

    u, v, w = list(map(int, input().split()))

    graph[u-1].append((v-1, w))

    graph[v-1].append((u-1, w))



color = [0 for _ in range(N)]

visited = [False for _ in range(N)]



def dfs(now):



    for adj in graph[now]:

        v, dist = adj

        if visited[v]:

            continue

        visited[v] = True

        color[v] = color[now] + dist

        dfs(v)



    return





for start in range(N):

    if not visited[start]:

        color[start] = 0

        visited[start] = True

        dfs(start)



for i in range(N):

    print((color[i] % 2))

from collections import deque

N = int(eval(input()))
dist = {}
graph = [[] for i in range(N)]
for i in range(1, N):
    u, v, w = list(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))

import sys

sys.setrecursionlimit(10**8)
N = int(eval(input()))
graph = [[] for _ in range(N)]
for i in range(1, N):
    u, v, w = list(map(int, input().split()))
    graph[u - 1].append((v - 1, w))
    graph[v - 1].append((u - 1, w))
color = [0 for _ in range(N)]
visited = [False for _ in range(N)]


def dfs(now):
    for adj in graph[now]:
        v, dist = adj
        if visited[v]:
            continue
        visited[v] = True
        color[v] = color[now] + dist
        dfs(v)
    return


for start in range(N):
    if not visited[start]:
        color[start] = 0
        visited[start] = True
        dfs(start)
for i in range(N):
    print((color[i] % 2))

-from collections import deque +import sys +sys.setrecursionlimit(10**8) -dist = {} -graph = [[] for i in range(N)] +graph = [[] for _ in range(N)] -    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() +    graph[u - 1].append((v - 1, w)) +    graph[v - 1].append((u - 1, w)) +color = [0 for _ in range(N)] +visited = [False for _ in range(N)] + + +def dfs(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) +        v, dist = adj +        if visited[v]: +            continue +        visited[v] = True +        color[v] = color[now] + dist +        dfs(v) +    return + + +for start in range(N): +    if not visited[start]: +        color[start] = 0 +        visited[start] = True +        dfs(start)