from collections import deque

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

colors = [-1 for _ in range(N)]
stack = deque()
stack.append(0)
colors[0] = 0

while stack:
    n = stack.popleft()
    for _next, w in graph[n]:
        if colors[_next] != -1:
            continue
        colors[_next] = (colors[n] + w) % 2
        stack.append(_next)

for c in colors:
    print(c) from collections import deque 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 _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    graph[u].append([v, w])
    graph[v].append([u, w]) _ 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 u, v = u - 1, v - 1 u u - 1 u 1 v v - 1 v 1 graph[u].append([v, w]) [u].append [u] graph u append [v, w] v w graph[v].append([u, w]) [v].append [v] graph v append [u, w] u w -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)] stack = deque() stack deque() deque stack.append(0) stack.append stack append 0 colors[0] = 0 colors[0] colors 0 0 while stack:
    n = stack.popleft()
    for _next, w in graph[n]:
        if colors[_next] != -1:
            continue
        colors[_next] = (colors[n] + w) % 2
        stack.append(_next) stack n = stack.popleft() n stack.popleft() stack.popleft stack popleft for _next, w in graph[n]:
        if colors[_next] != -1:
            continue
        colors[_next] = (colors[n] + w) % 2
        stack.append(_next) _next w graph[n] graph n if colors[_next] != -1:
            continue
         colors[_next] != -1 colors[_next] colors _next -1 continue colors[_next] = (colors[n] + w) % 2 colors[_next] colors _next (colors[n] + w) % 2 colors[n] + w colors[n] colors n w 2 stack.append(_next) stack.append stack append _next for c in colors:
    print(c) c colors print(c) print c v = u - 1, v - 1 v - 1 v stack = deque() deque() stack u, v = u - 1, v - 1 u - 1 u u, v, w = map(int, input().split()) map(int, input().split()) u graph = [[] for _ in range(N)] [[] for _ in range(N)] graph v, w = map(int, input().split()) map(int, input().split()) v w = map(int, input().split()) map(int, input().split()) w colors = [-1 for _ in range(N)] [-1 for _ in range(N)] colors N = int(input()) int(input()) N n = stack.popleft() stack.popleft() n
from collections import deque

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

colors = [-1 for _ in range(N)]
stack = deque()
stack.append(0)
colors[0] = 0

while stack:
    n = stack.popleft()
    for _next, w in graph[n]:
        if colors[_next] != -1:
            continue
        colors[_next] = (colors[n] + w) % 2
        stack.append(_next)

for c in colors:
    print(c)
