import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
edges = [[]for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    edges[u-1].append((w, v-1))
    edges[v-1].append((w, u-1))


color = [-1]*n


def dfs(v, d, parent):
    color[v] = d & 1
    for d2, v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, d+d2, v)


dfs(0, 0, -1)
print(*color, sep='\n') import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 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((w, v-1))
    edges[v-1].append((w, u-1)) _ 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((w, v-1)) [u-1].append [u-1] edges u-1 u 1 append (w, v-1) w v-1 v 1 edges[v-1].append((w, u-1)) [v-1].append [v-1] edges v-1 v 1 append (w, u-1) w u-1 u 1 color = [-1]*n color [-1]*n [-1] -1 n def dfs(v, d, parent):
    color[v] = d & 1
    for d2, v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, d+d2, v) dfs color[v] = d & 1 color[v] color v d & 1 d 1 for d2, v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, d+d2, v) d2 v2 edges[v] edges v if v2 == parent:
            continue
         v2 == parent v2 parent continue dfs(v2, d+d2, v) dfs v2 d+d2 d d2 v v v d d parent parent dfs(0, 0, -1) dfs 0 0 -1 print(*color, sep='\n') print *color color sep='\n' sep '\n' n = int(input()) int(input()) n edges = [[]for _ in range(n)] [[]for _ in range(n)] edges v, w = map(int, input().split()) map(int, input().split()) v w = map(int, input().split()) map(int, input().split()) w def dfs(v, d, parent):
    color[v] = d & 1
    for d2, v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, d+d2, v) def dfs(v, d, parent):
    color[v] = d & 1
    for d2, v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, d+d2, v) dfs color = [-1]*n [-1]*n color input = sys.stdin.readline sys.stdin.readline input u, v, w = map(int, input().split()) map(int, input().split()) u
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
edges = [[]for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    edges[u-1].append((w, v-1))
    edges[v-1].append((w, u-1))


color = [-1]*n


def dfs(v, d, parent):
    color[v] = d & 1
    for d2, v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, d+d2, v)


dfs(0, 0, -1)
print(*color, sep='\n')