def BFS(x):
    v = deque([x])
    d[x]=0
    
    while v:
        a = v.popleft()
        for num in L[a]:
            if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num)

from collections import deque
N=int(input())
u=[0]*(N-1)
v=[0]*(N-1)
w=[0]*(N-1)
d=[-1 for _ in range(N)]
dic={}
L=[ [] for _ in range(N)]
for i in range(N-1):
    u[i],v[i],w[i] = map(int,input().split())
    u[i] -=1
    v[i] -=1
    L[u[i]].append(v[i])
    L[v[i]].append(u[i])
    dic[ (u[i],v[i])]=w[i]
    dic[ (v[i],u[i])]=w[i]
    
#print(L)
#print(dic)

BFS(0)
#print(d)
for num in d:
    if num%2==0:
        print(0)
    else:
        print(1) def BFS(x):
    v = deque([x])
    d[x]=0
    
    while v:
        a = v.popleft()
        for num in L[a]:
            if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num) BFS v = deque([x]) v deque([x]) deque [x] x d[x]=0 d[x] d x 0 while v:
        a = v.popleft()
        for num in L[a]:
            if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num) v a = v.popleft() a v.popleft() v.popleft v popleft for num in L[a]:
            if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num) num L[a] L a if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num) d[num]==-1 d[num] d num -1 d[num]= d[a]+dic[(a,num)] d[num] d num d[a]+dic[(a,num)] d[a] d a dic[(a,num)] dic (a,num) a num v.append(num) v.append v append num x x from collections import deque N=int(input()) N int(input()) int input() input u=[0]*(N-1) u [0]*(N-1) [0] 0 N-1 N 1 v=[0]*(N-1) v [0]*(N-1) [0] 0 N-1 N 1 w=[0]*(N-1) w [0]*(N-1) [0] 0 N-1 N 1 -1 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) -1 d=[-1 for _ in range(N)] d [-1 for _ in range(N)] dic={} dic {} [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] L=[ [] for _ in range(N)] L [ [] for _ in range(N)] for i in range(N-1):
    u[i],v[i],w[i] = map(int,input().split())
    u[i] -=1
    v[i] -=1
    L[u[i]].append(v[i])
    L[v[i]].append(u[i])
    dic[ (u[i],v[i])]=w[i]
    dic[ (v[i],u[i])]=w[i]
    
#print(L)
#print(dic) i range(N-1) range N-1 N 1 u[i],v[i],w[i] = map(int,input().split()) u[i] u i map(int,input().split()) map int input().split() ().split () input split v[i] v i w[i] w i u[i] -=1 u[i] u i 1 v[i] -=1 v[i] v i 1 L[u[i]].append(v[i]) [u[i]].append [u[i]] L u[i] u i append v[i] v i L[v[i]].append(u[i]) [v[i]].append [v[i]] L v[i] v i append u[i] u i dic[ (u[i],v[i])]=w[i] dic[ (u[i],v[i])] dic (u[i],v[i]) u[i] u i v[i] v i w[i] w i dic[ (v[i],u[i])]=w[i] dic[ (v[i],u[i])] dic (v[i],u[i]) v[i] v i u[i] u i w[i] w i BFS(0) BFS 0 for num in d:
    if num%2==0:
        print(0)
    else:
        print(1) num d if num%2==0:
        print(0)
    else:
        print(1) num%2==0 num%2 num 2 0 print(0) print 0 print(1) print 1 d=[-1 for _ in range(N)] [-1 for _ in range(N)] d def BFS(x):
    v = deque([x])
    d[x]=0
    
    while v:
        a = v.popleft()
        for num in L[a]:
            if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num) def BFS(x):
    v = deque([x])
    d[x]=0
    
    while v:
        a = v.popleft()
        for num in L[a]:
            if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num) BFS v=[0]*(N-1) [0]*(N-1) v L=[ [] for _ in range(N)] [ [] for _ in range(N)] L N=int(input()) int(input()) N w=[0]*(N-1) [0]*(N-1) w dic={} {} dic u=[0]*(N-1) [0]*(N-1) u
def BFS(x):
    v = deque([x])
    d[x]=0
    
    while v:
        a = v.popleft()
        for num in L[a]:
            if d[num]==-1:
                d[num]= d[a]+dic[(a,num)]
                v.append(num)

from collections import deque
N=int(input())
u=[0]*(N-1)
v=[0]*(N-1)
w=[0]*(N-1)
d=[-1 for _ in range(N)]
dic={}
L=[ [] for _ in range(N)]
for i in range(N-1):
    u[i],v[i],w[i] = map(int,input().split())
    u[i] -=1
    v[i] -=1
    L[u[i]].append(v[i])
    L[v[i]].append(u[i])
    dic[ (u[i],v[i])]=w[i]
    dic[ (v[i],u[i])]=w[i]
    
#print(L)
#print(dic)

BFS(0)
#print(d)
for num in d:
    if num%2==0:
        print(0)
    else:
        print(1)