import collections

n = int(input())
graph = [[] for i in range(n + 1)]
flag = [False for i in range(n + 1)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].append([v, w])
    graph[v].append([u, w])
color = [None for i in range(n + 1)]
color[1] = 0
queue = collections.deque([1])
while queue:
    test = queue.popleft()
    flag[test] = True
    for i in graph[test]:
        if flag[i[0]] == True:
            continue
        queue.append(i[0])
        color[i[0]] = i[1] % 2 ^ color[test]
for i in range(n):
    print(color[i + 1]) import collections collections n = int(input()) n int(input()) int input() input [] for i in range(n + 1) for i in range(n + 1) i range(n + 1) range n + 1 n 1 for i in range(n + 1) [] graph = [[] for i in range(n + 1)] graph [[] for i in range(n + 1)] False for i in range(n + 1) for i in range(n + 1) i range(n + 1) range n + 1 n 1 for i in range(n + 1) False flag = [False for i in range(n + 1)] flag [False for i in range(n + 1)] for i in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].append([v, w])
    graph[v].append([u, 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 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 None for i in range(n + 1) for i in range(n + 1) i range(n + 1) range n + 1 n 1 for i in range(n + 1) None color = [None for i in range(n + 1)] color [None for i in range(n + 1)] color[1] = 0 color[1] color 1 0 queue = collections.deque([1]) queue collections.deque([1]) collections.deque collections deque [1] 1 while queue:
    test = queue.popleft()
    flag[test] = True
    for i in graph[test]:
        if flag[i[0]] == True:
            continue
        queue.append(i[0])
        color[i[0]] = i[1] % 2 ^ color[test] queue test = queue.popleft() test queue.popleft() queue.popleft queue popleft flag[test] = True flag[test] flag test True for i in graph[test]:
        if flag[i[0]] == True:
            continue
        queue.append(i[0])
        color[i[0]] = i[1] % 2 ^ color[test] i graph[test] graph test if flag[i[0]] == True:
            continue
         flag[i[0]] == True flag[i[0]] flag i[0] i 0 True continue queue.append(i[0]) queue.append queue append i[0] i 0 color[i[0]] = i[1] % 2 ^ color[test] color[i[0]] color i[0] i 0 i[1] % 2 ^ color[test] i[1] % 2 i[1] i 1 2 color[test] color test for i in range(n):
    print(color[i + 1]) i range(n) range n print(color[i + 1]) print color[i + 1] color i + 1 i 1 w = map(int, input().split()) map(int, input().split()) w test = queue.popleft() queue.popleft() test u, v, w = map(int, input().split()) map(int, input().split()) u v, w = map(int, input().split()) map(int, input().split()) v color = [None for i in range(n + 1)] [None for i in range(n + 1)] color n = int(input()) int(input()) n flag = [False for i in range(n + 1)] [False for i in range(n + 1)] flag graph = [[] for i in range(n + 1)] [[] for i in range(n + 1)] graph queue = collections.deque([1]) collections.deque([1]) queue
import collections

n = int(input())
graph = [[] for i in range(n + 1)]
flag = [False for i in range(n + 1)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].append([v, w])
    graph[v].append([u, w])
color = [None for i in range(n + 1)]
color[1] = 0
queue = collections.deque([1])
while queue:
    test = queue.popleft()
    flag[test] = True
    for i in graph[test]:
        if flag[i[0]] == True:
            continue
        queue.append(i[0])
        color[i[0]] = i[1] % 2 ^ color[test]
for i in range(n):
    print(color[i + 1])