import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
    return dist

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

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

dist = bfs()
ans = [0]*N

for i in range(N):
    if dist[i]%2==0:
        ans[i] = 1

for ans_i in ans:
    print(ans_i) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import * def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
    return dist bfs q = deque([0]) q deque([0]) deque [0] 0 dist = [-1]*N dist [-1]*N [-1] -1 N dist[0] = 0 dist[0] dist 0 0 while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
     q v = q.popleft() v q.popleft() q.popleft q popleft for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
     nv w G[v] G v if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
     dist[nv]==-1 dist[nv] dist nv -1 dist[nv] = dist[v]+w dist[nv] dist nv dist[v]+w dist[v] dist v w q.append(nv) q.append q append nv return dist dist 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) [] G = [[] for _ in range(N)] G [[] for _ in range(N)] for _ in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append((v-1, w))
    G[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 G[u-1].append((v-1, w)) [u-1].append [u-1] G u-1 u 1 append (v-1, w) v-1 v 1 w G[v-1].append((u-1, w)) [v-1].append [v-1] G v-1 v 1 append (u-1, w) u-1 u 1 w dist = bfs() dist bfs() bfs ans = [0]*N ans [0]*N [0] 0 N for i in range(N):
    if dist[i]%2==0:
        ans[i] = 1 i range(N) range N if dist[i]%2==0:
        ans[i] = 1 dist[i]%2==0 dist[i]%2 dist[i] dist i 2 0 ans[i] = 1 ans[i] ans i 1 for ans_i in ans:
    print(ans_i) ans_i ans print(ans_i) print ans_i input = sys.stdin.readline sys.stdin.readline input ans = [0]*N [0]*N ans w = map(int, input().split()) map(int, input().split()) w v, w = map(int, input().split()) map(int, input().split()) v def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
    return dist def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
    return dist bfs N = int(input()) int(input()) N u, v, w = map(int, input().split()) map(int, input().split()) u G = [[] for _ in range(N)] [[] for _ in range(N)] G dist = bfs() bfs() dist
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    dist = [-1]*N
    dist[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+w
                q.append(nv)
        
    return dist

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

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

dist = bfs()
ans = [0]*N

for i in range(N):
    if dist[i]%2==0:
        ans[i] = 1

for ans_i in ans:
    print(ans_i)