import sys,math,collections,itertools
input = sys.stdin.readline
#ダイクストラで頂点1と偶数距離を0として塗る
N=int(input())
road=[[] for i in range(N+1)]
for _ in range(N-1):
    u,v,w=list(map(int,input().split()))
    road[u].append((v,w))
    road[v].append((u,w))
dist = [float('inf')for i in range(N+1)]
ans = [0]*(N+1)

q = collections.deque([])
q.append(1)
dist[1]=0
while q:
    now = q.popleft()
    for goto,cost in road[now]:
        if dist[goto]>dist[now]+cost:
            dist[goto]=dist[now]+cost
            q.append(goto)

for a in dist[1:]:
    print(a%2) import sys,math,collections,itertools sys math collections itertools input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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) [] road=[[] for i in range(N+1)] road [[] for i in range(N+1)] for _ in range(N-1):
    u,v,w=list(map(int,input().split()))
    road[u].append((v,w))
    road[v].append((u,w)) _ range(N-1) range N-1 N 1 u,v,w=list(map(int,input().split())) u list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split v w road[u].append((v,w)) [u].append [u] road u append (v,w) v w road[v].append((u,w)) [v].append [v] road v append (u,w) u w float('inf')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) float('inf') float 'inf' dist = [float('inf')for i in range(N+1)] dist [float('inf')for i in range(N+1)] ans = [0]*(N+1) ans [0]*(N+1) [0] 0 N+1 N 1 q = collections.deque([]) q collections.deque([]) collections.deque collections deque [] q.append(1) q.append q append 1 dist[1]=0 dist[1] dist 1 0 while q:
    now = q.popleft()
    for goto,cost in road[now]:
        if dist[goto]>dist[now]+cost:
            dist[goto]=dist[now]+cost
            q.append(goto) q now = q.popleft() now q.popleft() q.popleft q popleft for goto,cost in road[now]:
        if dist[goto]>dist[now]+cost:
            dist[goto]=dist[now]+cost
            q.append(goto) goto cost road[now] road now if dist[goto]>dist[now]+cost:
            dist[goto]=dist[now]+cost
            q.append(goto) dist[goto]>dist[now]+cost dist[goto] dist goto dist[now]+cost dist[now] dist now cost dist[goto]=dist[now]+cost dist[goto] dist goto dist[now]+cost dist[now] dist now cost q.append(goto) q.append q append goto for a in dist[1:]:
    print(a%2) a dist[1:] dist 1: 1 print(a%2) print a%2 a 2 input = sys.stdin.readline sys.stdin.readline input dist = [float('inf')for i in range(N+1)] [float('inf')for i in range(N+1)] dist v,w=list(map(int,input().split())) list(map(int,input().split())) v u,v,w=list(map(int,input().split())) list(map(int,input().split())) u ans = [0]*(N+1) [0]*(N+1) ans road=[[] for i in range(N+1)] [[] for i in range(N+1)] road w=list(map(int,input().split())) list(map(int,input().split())) w q = collections.deque([]) collections.deque([]) q now = q.popleft() q.popleft() now N=int(input()) int(input()) N
import sys,math,collections,itertools
input = sys.stdin.readline
#ダイクストラで頂点1と偶数距離を0として塗る
N=int(input())
road=[[] for i in range(N+1)]
for _ in range(N-1):
    u,v,w=list(map(int,input().split()))
    road[u].append((v,w))
    road[v].append((u,w))
dist = [float('inf')for i in range(N+1)]
ans = [0]*(N+1)

q = collections.deque([])
q.append(1)
dist[1]=0
while q:
    now = q.popleft()
    for goto,cost in road[now]:
        if dist[goto]>dist[now]+cost:
            dist[goto]=dist[now]+cost
            q.append(goto)

for a in dist[1:]:
    print(a%2)
