import sys
sys.setrecursionlimit(20000000)


def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size)


N = int(input())

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

ans = [-1]*N
dfs(0, 0)
print(*ans, sep='\n') import sys sys sys.setrecursionlimit(20000000) sys.setrecursionlimit sys setrecursionlimit 20000000 def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size) dfs for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size) next_node edge_size G[node] G node if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size) ans[next_node] == -1 ans[next_node] ans next_node -1 ans[next_node] = ((distance+edge_size) % 2) ans[next_node] ans next_node (distance+edge_size) % 2 distance+edge_size distance edge_size 2 dfs(next_node, distance+edge_size) dfs next_node distance+edge_size distance edge_size node node distance distance 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 = map(int, input().split())
    G[u-1].append([v-1, w])
    G[v-1].append([u-1, 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 G[u-1].append([v-1, w]) [u-1].append [u-1] G u-1 u 1 append [v-1, w] v-1 v 1 w G[v-1].append([u-1, w]) [v-1].append [v-1] G v-1 v 1 append [u-1, w] u-1 u 1 w ans = [-1]*N ans [-1]*N [-1] -1 N dfs(0, 0) dfs 0 0 print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' G = [[] for i in range(N)] [[] for i in range(N)] G w = map(int, input().split()) map(int, input().split()) w ans = [-1]*N [-1]*N ans N = int(input()) int(input()) N u, v, w = map(int, input().split()) map(int, input().split()) u def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size) def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size) dfs v, w = map(int, input().split()) map(int, input().split()) v
import sys
sys.setrecursionlimit(20000000)


def dfs(node, distance):
    for next_node, edge_size in G[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((distance+edge_size) % 2)
            dfs(next_node, distance+edge_size)


N = int(input())

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

ans = [-1]*N
dfs(0, 0)
print(*ans, sep='\n')