import sys
sys.setrecursionlimit(10**7)

N=int(input())
graph=[[] for _ in range(N)]

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

color=[-1]*N
def even(v=0,col=0):
    color[v]=col
    for i in range(len(graph[v])):
        nv,nw=map(int,graph[v][i])
        if color[nv]!=-1: continue
        if nw%2==0:
            even(nv,col)
        else:
            even(nv,1-col)

even()
for i in range(N):
    print(color[i]) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 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-=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-=1 u 1 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 color=[-1]*N color [-1]*N [-1] -1 N def even(v=0,col=0):
    color[v]=col
    for i in range(len(graph[v])):
        nv,nw=map(int,graph[v][i])
        if color[nv]!=-1: continue
        if nw%2==0:
            even(nv,col)
        else:
            even(nv,1-col) even color[v]=col color[v] color v col for i in range(len(graph[v])):
        nv,nw=map(int,graph[v][i])
        if color[nv]!=-1: continue
        if nw%2==0:
            even(nv,col)
        else:
            even(nv,1-col) i range(len(graph[v])) range len(graph[v]) len graph[v] graph v nv,nw=map(int,graph[v][i]) nv map(int,graph[v][i]) map int graph[v][i] [v] graph v i nw if color[nv]!=-1: continue
         color[nv]!=-1 color[nv] color nv -1 if nw%2==0:
            even(nv,col)
        else:
            even(nv,1-col) nw%2==0 nw%2 nw 2 0 even(nv,col) even nv col even(nv,1-col) even nv 1-col 1 col v=0 v 0 col=0 col 0 even() even for i in range(N):
    print(color[i]) i range(N) range N print(color[i]) print color[i] color i u-=1 1 u color=[-1]*N [-1]*N color graph=[[] for _ in range(N)] [[] for _ in range(N)] graph N=int(input()) int(input()) N def even(v=0,col=0):
    color[v]=col
    for i in range(len(graph[v])):
        nv,nw=map(int,graph[v][i])
        if color[nv]!=-1: continue
        if nw%2==0:
            even(nv,col)
        else:
            even(nv,1-col) def even(v=0,col=0):
    color[v]=col
    for i in range(len(graph[v])):
        nv,nw=map(int,graph[v][i])
        if color[nv]!=-1: continue
        if nw%2==0:
            even(nv,col)
        else:
            even(nv,1-col) even v-=1 1 v u,v,w=map(int,input().split()) map(int,input().split()) u v,w=map(int,input().split()) map(int,input().split()) v w=map(int,input().split()) map(int,input().split()) w
import sys
sys.setrecursionlimit(10**7)

N=int(input())
graph=[[] for _ in range(N)]

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

color=[-1]*N
def even(v=0,col=0):
    color[v]=col
    for i in range(len(graph[v])):
        nv,nw=map(int,graph[v][i])
        if color[nv]!=-1: continue
        if nw%2==0:
            even(nv,col)
        else:
            even(nv,1-col)

even()
for i in range(N):
    print(color[i])
