import sys
n = int(input())
sys.setrecursionlimit(2*n)
graph = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))
colors = [None]*n
colors[0] = 0
def DFS(node):
    for c_node, l in graph[node]:
        if colors[c_node] is not None:
            continue
        colors[c_node] = (l+colors[node])%2
        DFS(c_node)
DFS(0)
for i in colors:
    print(i) import sys sys n = int(input()) n int(input()) int input() input sys.setrecursionlimit(2*n) sys.setrecursionlimit sys setrecursionlimit 2*n 2 n [] 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())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, 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 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 colors = [None]*n colors [None]*n [None] None n colors[0] = 0 colors[0] colors 0 0 def DFS(node):
    for c_node, l in graph[node]:
        if colors[c_node] is not None:
            continue
        colors[c_node] = (l+colors[node])%2
        DFS(c_node) DFS for c_node, l in graph[node]:
        if colors[c_node] is not None:
            continue
        colors[c_node] = (l+colors[node])%2
        DFS(c_node) c_node l graph[node] graph node if colors[c_node] is not None:
            continue
         colors[c_node] is not None colors[c_node] colors c_node None continue colors[c_node] = (l+colors[node])%2 colors[c_node] colors c_node (l+colors[node])%2 l+colors[node] l colors[node] colors node 2 DFS(c_node) DFS c_node node node DFS(0) DFS 0 for i in colors:
    print(i) i colors print(i) print i def DFS(node):
    for c_node, l in graph[node]:
        if colors[c_node] is not None:
            continue
        colors[c_node] = (l+colors[node])%2
        DFS(c_node) def DFS(node):
    for c_node, l in graph[node]:
        if colors[c_node] is not None:
            continue
        colors[c_node] = (l+colors[node])%2
        DFS(c_node) DFS v, w = map(int, input().split()) map(int, input().split()) v n = int(input()) int(input()) n u, v, w = map(int, input().split()) map(int, input().split()) u graph = [[] for _ in range(n)] [[] for _ in range(n)] graph colors = [None]*n [None]*n colors w = map(int, input().split()) map(int, input().split()) w
import sys
n = int(input())
sys.setrecursionlimit(2*n)
graph = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))
colors = [None]*n
colors[0] = 0
def DFS(node):
    for c_node, l in graph[node]:
        if colors[c_node] is not None:
            continue
        colors[c_node] = (l+colors[node])%2
        DFS(c_node)
DFS(0)
for i in colors:
    print(i)