"""bfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())

to = [[] for _ in range(n)]
cost = [[] for _ in range(n)]

for i in range(n-1):
    a,b,w = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); cost[a].append(w)
    to[b].append(a); cost[b].append(w)

ans = [-1]*n # 頂点を探索済みかどうか判定するために初期値を-1に
ans[0] = 0

import queue

q = queue.Queue()
q.put(0)

while not q.empty():
    v = q.get()
    for i in range(len(to[v])):
        u = to[v][i]
        w = cost[v][i]
        if ans[u] != -1: continue
        ans[u] = (ans[v]+w)%2
        q.put(u)
        
print(*ans) """bfs""" import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 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) [] to = [[] for _ in range(n)] to [[] for _ in range(n)] [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] cost = [[] for _ in range(n)] cost [[] for _ in range(n)] for i in range(n-1):
    a,b,w = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); cost[a].append(w)
    to[b].append(a); cost[b].append(w) i range(n-1) range n-1 n 1 a,b,w = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b w a -= 1 a 1 b -= 1 b 1 to[a].append(b) [a].append [a] to a append b cost[a].append(w) [a].append [a] cost a append w to[b].append(a) [b].append [b] to b append a cost[b].append(w) [b].append [b] cost b append w ans = [-1]*n ans [-1]*n [-1] -1 n ans[0] = 0 ans[0] ans 0 0 import queue queue q = queue.Queue() q queue.Queue() queue.Queue queue Queue q.put(0) q.put q put 0 while not q.empty():
    v = q.get()
    for i in range(len(to[v])):
        u = to[v][i]
        w = cost[v][i]
        if ans[u] != -1: continue
        ans[u] = (ans[v]+w)%2
        q.put(u)
         not q.empty() q.empty() q.empty q empty v = q.get() v q.get() q.get q get for i in range(len(to[v])):
        u = to[v][i]
        w = cost[v][i]
        if ans[u] != -1: continue
        ans[u] = (ans[v]+w)%2
        q.put(u)
         i range(len(to[v])) range len(to[v]) len to[v] to v u = to[v][i] u to[v][i] [v] to v i w = cost[v][i] w cost[v][i] [v] cost v i if ans[u] != -1: continue
         ans[u] != -1 ans[u] ans u -1 ans[u] = (ans[v]+w)%2 ans[u] ans u (ans[v]+w)%2 ans[v]+w ans[v] ans v w 2 q.put(u) q.put q put u print(*ans) print *ans ans a,b,w = map(int, input().split()) map(int, input().split()) a n = int(input()) int(input()) n b,w = map(int, input().split()) map(int, input().split()) b ans = [-1]*n [-1]*n ans to = [[] for _ in range(n)] [[] for _ in range(n)] to b -= 1 1 b w = map(int, input().split()) map(int, input().split()) w u = to[v][i] to[v][i] u a -= 1 1 a q = queue.Queue() queue.Queue() q cost = [[] for _ in range(n)] [[] for _ in range(n)] cost v = q.get() q.get() v w = cost[v][i] cost[v][i] w
"""bfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())

to = [[] for _ in range(n)]
cost = [[] for _ in range(n)]

for i in range(n-1):
    a,b,w = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); cost[a].append(w)
    to[b].append(a); cost[b].append(w)

ans = [-1]*n # 頂点を探索済みかどうか判定するために初期値を-1に
ans[0] = 0

import queue

q = queue.Queue()
q.put(0)

while not q.empty():
    v = q.get()
    for i in range(len(to[v])):
        u = to[v][i]
        w = cost[v][i]
        if ans[u] != -1: continue
        ans[u] = (ans[v]+w)%2
        q.put(u)
        
print(*ans)