import sys
sys.setrecursionlimit(10**8)
N = int(input())
graph = [[] for _ in range(N)]

for i in range(1, N):
    u, v, w = 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) import sys sys sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 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) [] graph = [[] for _ in range(N)] graph [[] for _ in range(N)] for i in range(1, N):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-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, w)) [u-1].append [u-1] graph u-1 u 1 append (v-1, w) v-1 v 1 w graph[v-1].append((u-1, w)) [v-1].append [v-1] graph v-1 v 1 append (u-1, w) u-1 u 1 w 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 color = [0 for _ in range(N)] color [0 for _ in range(N)] False for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) False visited = [False 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 dfs for adj in graph[now]:
        v, dist = adj
        if visited[v]:
            continue
        visited[v] = True
        color[v] = color[now] + dist
        dfs(v)

     adj graph[now] graph now v, dist = adj v adj dist if visited[v]:
            continue
         visited[v] visited v continue visited[v] = True visited[v] visited v True color[v] = color[now] + dist color[v] color v color[now] + dist color[now] color now dist dfs(v) dfs v return now now for start in range(N):
    if not visited[start]:
        color[start] = 0
        visited[start] = True
        dfs(start) start range(N) range N if not visited[start]:
        color[start] = 0
        visited[start] = True
        dfs(start) not visited[start] visited[start] visited start color[start] = 0 color[start] color start 0 visited[start] = True visited[start] visited start True dfs(start) dfs start 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 w = map(int, input().split()) map(int, input().split()) w u, v, w = map(int, input().split()) map(int, input().split()) u color = [0 for _ in range(N)] [0 for _ in range(N)] color N = int(input()) int(input()) N v, w = map(int, input().split()) map(int, input().split()) v visited = [False for _ in range(N)] [False for _ in range(N)] visited graph = [[] for _ in range(N)] [[] for _ in range(N)] graph 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 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 dfs
import sys
sys.setrecursionlimit(10**8)
N = int(input())
graph = [[] for _ in range(N)]

for i in range(1, N):
    u, v, w = 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)
