import sys
sys.setrecursionlimit(10**8)
N = int(input())
UVW = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for u,v,w in UVW:
    u,v = u-1,v-1
    es[u].append((v,w))
    es[v].append((u,w))

ans = [None] * N
ans[0] = 0

def dfs(v,p=-1):
    for to,d in es[v]:
        if to==p: continue
        ans[to] = ans[v] ^ (d%2)
        dfs(to,v)
dfs(0)

print(*ans, sep='\n') import sys sys sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 N = int(input()) N int(input()) int input() input tuple(map(int,input().split())) 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) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split UVW = [tuple(map(int,input().split())) for i in range(N-1)] UVW [tuple(map(int,input().split())) for i in range(N-1)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] es = [[] for _ in range(N)] es [[] for _ in range(N)] for u,v,w in UVW:
    u,v = u-1,v-1
    es[u].append((v,w))
    es[v].append((u,w)) u v w UVW u,v = u-1,v-1 u u-1 u 1 v v-1 v 1 es[u].append((v,w)) [u].append [u] es u append (v,w) v w es[v].append((u,w)) [v].append [v] es v append (u,w) u w ans = [None] * N ans [None] * N [None] None N ans[0] = 0 ans[0] ans 0 0 def dfs(v,p=-1):
    for to,d in es[v]:
        if to==p: continue
        ans[to] = ans[v] ^ (d%2)
        dfs(to,v) dfs for to,d in es[v]:
        if to==p: continue
        ans[to] = ans[v] ^ (d%2)
        dfs(to,v) to d es[v] es v if to==p: continue
         to==p to p ans[to] = ans[v] ^ (d%2) ans[to] ans to ans[v] ^ (d%2) ans[v] ans v d%2 d 2 dfs(to,v) dfs to v v v p=-1 p -1 dfs(0) dfs 0 print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' UVW = [tuple(map(int,input().split())) for i in range(N-1)] [tuple(map(int,input().split())) for i in range(N-1)] UVW es = [[] for _ in range(N)] [[] for _ in range(N)] es u,v = u-1,v-1 u-1 u def dfs(v,p=-1):
    for to,d in es[v]:
        if to==p: continue
        ans[to] = ans[v] ^ (d%2)
        dfs(to,v) def dfs(v,p=-1):
    for to,d in es[v]:
        if to==p: continue
        ans[to] = ans[v] ^ (d%2)
        dfs(to,v) dfs v = u-1,v-1 v-1 v ans = [None] * N [None] * N ans N = int(input()) int(input()) N
import sys
sys.setrecursionlimit(10**8)
N = int(input())
UVW = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for u,v,w in UVW:
    u,v = u-1,v-1
    es[u].append((v,w))
    es[v].append((u,w))

ans = [None] * N
ans[0] = 0

def dfs(v,p=-1):
    for to,d in es[v]:
        if to==p: continue
        ans[to] = ans[v] ^ (d%2)
        dfs(to,v)
dfs(0)

print(*ans, sep='\n')