#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (int)
N = int(input().rstrip())

# N ✕ M (2D array)
A = list(map(int, input().rstrip().split()) for _ in range(N - 1))

items = [[] for _ in range(N)]
colors = [-1 for _ in range(N)]

for i in range(N - 1):
    a, b, w = A[i]
    items[a - 1].append((b - 1, w))
    items[b - 1].append((a - 1, w))

queue = collections.deque()
queue.append(0)
colors[0] = 0
while queue:
    v = queue.popleft()
    c = colors[v]
    for k, w in items[v]:
        cc = colors[k]
        if cc == -1:
            nc = c if w % 2 == 0 else not c
            colors[k] = nc
            queue.append(k)

# def dfs(v, c):
#     colors[v] = c
#
#     cc = colors[k]
#
#     if cc == -1:
#         if not dfs(k, nc):
#             return False
#     else:
#         if colors[i] != nc:
#             return False
#
#
# return True
#
# dfs(0, True)
for c in colors:
    print(int(not c)) import sys sys import collections collections sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 N = int(input().rstrip()) N int(input().rstrip()) int input().rstrip() ().rstrip () input rstrip A = list(map(int, input().rstrip().split()) for _ in range(N - 1)) A list(map(int, input().rstrip().split()) for _ in range(N - 1)) list map(int, input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] items = [[] for _ in range(N)] items [[] for _ in range(N)] -1 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) -1 colors = [-1 for _ in range(N)] colors [-1 for _ in range(N)] for i in range(N - 1):
    a, b, w = A[i]
    items[a - 1].append((b - 1, w))
    items[b - 1].append((a - 1, w)) i range(N - 1) range N - 1 N 1 a, b, w = A[i] a A[i] A i b w items[a - 1].append((b - 1, w)) [a - 1].append [a - 1] items a - 1 a 1 append (b - 1, w) b - 1 b 1 w items[b - 1].append((a - 1, w)) [b - 1].append [b - 1] items b - 1 b 1 append (a - 1, w) a - 1 a 1 w queue = collections.deque() queue collections.deque() collections.deque collections deque queue.append(0) queue.append queue append 0 colors[0] = 0 colors[0] colors 0 0 while queue:
    v = queue.popleft()
    c = colors[v]
    for k, w in items[v]:
        cc = colors[k]
        if cc == -1:
            nc = c if w % 2 == 0 else not c
            colors[k] = nc
            queue.append(k)

# def dfs(v, c):
#     colors[v] = c
#
#     cc = colors[k]
#
#     if cc == -1:
#         if not dfs(k, nc):
#             return False
#     else:
#         if colors[i] != nc:
#             return False
#
#
# return True
#
# dfs(0, True) queue v = queue.popleft() v queue.popleft() queue.popleft queue popleft c = colors[v] c colors[v] colors v for k, w in items[v]:
        cc = colors[k]
        if cc == -1:
            nc = c if w % 2 == 0 else not c
            colors[k] = nc
            queue.append(k)

# def dfs(v, c):
#     colors[v] = c
#
#     cc = colors[k]
#
#     if cc == -1:
#         if not dfs(k, nc):
#             return False
#     else:
#         if colors[i] != nc:
#             return False
#
#
# return True
#
# dfs(0, True) k w items[v] items v cc = colors[k] cc colors[k] colors k if cc == -1:
            nc = c if w % 2 == 0 else not c
            colors[k] = nc
            queue.append(k)

# def dfs(v, c):
#     colors[v] = c
#
#     cc = colors[k]
#
#     if cc == -1:
#         if not dfs(k, nc):
#             return False
#     else:
#         if colors[i] != nc:
#             return False
#
#
# return True
#
# dfs(0, True) cc == -1 cc -1 nc = c if w % 2 == 0 else not c nc c if w % 2 == 0 else not c w % 2 == 0 w % 2 w 2 0 c not c c colors[k] = nc colors[k] colors k nc queue.append(k) queue.append queue append k for c in colors:
    print(int(not c)) c colors print(int(not c)) print int(not c) int not c c N = int(input().rstrip()) int(input().rstrip()) N items = [[] for _ in range(N)] [[] for _ in range(N)] items c = colors[v] colors[v] c cc = colors[k] colors[k] cc colors = [-1 for _ in range(N)] [-1 for _ in range(N)] colors nc = c if w % 2 == 0 else not c c if w % 2 == 0 else not c nc a, b, w = A[i] A[i] a w = A[i] A[i] w b, w = A[i] A[i] b queue = collections.deque() collections.deque() queue A = list(map(int, input().rstrip().split()) for _ in range(N - 1)) list(map(int, input().rstrip().split()) for _ in range(N - 1)) A v = queue.popleft() queue.popleft() v
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (int)
N = int(input().rstrip())

# N ✕ M (2D array)
A = list(map(int, input().rstrip().split()) for _ in range(N - 1))

items = [[] for _ in range(N)]
colors = [-1 for _ in range(N)]

for i in range(N - 1):
    a, b, w = A[i]
    items[a - 1].append((b - 1, w))
    items[b - 1].append((a - 1, w))

queue = collections.deque()
queue.append(0)
colors[0] = 0
while queue:
    v = queue.popleft()
    c = colors[v]
    for k, w in items[v]:
        cc = colors[k]
        if cc == -1:
            nc = c if w % 2 == 0 else not c
            colors[k] = nc
            queue.append(k)

# def dfs(v, c):
#     colors[v] = c
#
#     cc = colors[k]
#
#     if cc == -1:
#         if not dfs(k, nc):
#             return False
#     else:
#         if colors[i] != nc:
#             return False
#
#
# return True
#
# dfs(0, True)
for c in colors:
    print(int(not c))
