import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        u,v,w=MI()
        u-=1
        v-=1
        adj[u].append((v,w))
        adj[v].append((u,w))
        
    
    ans=[-1]*N
    import queue
    
    q=queue.Queue()
    q.put(0)
    ans[0]=0
    
    while not q.empty():
        v=q.get()
        for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
    for i in range(N):
        print(ans[i])
    
    

main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI def main():
    mod=10**9+7
    N=I()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        u,v,w=MI()
        u-=1
        v-=1
        adj[u].append((v,w))
        adj[v].append((u,w))
        
    
    ans=[-1]*N
    import queue
    
    q=queue.Queue()
    q.put(0)
    ans[0]=0
    
    while not q.empty():
        v=q.get()
        for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
    for i in range(N):
        print(ans[i])
    
     main mod=10**9+7 mod 10**9+7 10**9 10 9 7 N=I() N I() I []for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] adj=[[]for _ in range(N)] adj [[]for _ in range(N)] for i in range(N-1):
        u,v,w=MI()
        u-=1
        v-=1
        adj[u].append((v,w))
        adj[v].append((u,w))
        
    
     i range(N-1) range N-1 N 1 u,v,w=MI() u MI() MI v w u-=1 u 1 v-=1 v 1 adj[u].append((v,w)) [u].append [u] adj u append (v,w) v w adj[v].append((u,w)) [v].append [v] adj v append (u,w) u w ans=[-1]*N ans [-1]*N [-1] -1 N import queue queue q=queue.Queue() q queue.Queue() queue.Queue queue Queue q.put(0) q.put q put 0 ans[0]=0 ans[0] ans 0 0 while not q.empty():
        v=q.get()
        for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
     not q.empty() q.empty() q.empty q empty v=q.get() v q.get() q.get q get for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
     nv w adj[v] adj v if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
     ans[nv]==-1 ans[nv] ans nv -1 if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                 ans[v]==0 and w%2==0 ans[v]==0 ans[v] ans v 0 w%2==0 w%2 w 2 0 ans[nv]=0 ans[nv] ans nv 0 elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                 ans[v]==0 and w%2==1 ans[v]==0 ans[v] ans v 0 w%2==1 w%2 w 2 1 ans[nv]=1 ans[nv] ans nv 1 elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                 ans[v]==1 and w%2==0 ans[v]==1 ans[v] ans v 1 w%2==0 w%2 w 2 0 ans[nv]=1 ans[nv] ans nv 1 ans[nv]=0 ans[nv] ans nv 0 q.put(nv) q.put q put nv for i in range(N):
        print(ans[i])
    
     i range(N) range N print(ans[i]) print ans[i] ans i main() main input = sys.stdin.readline sys.stdin.readline input def I(): return int(input()) def I(): return int(input()) I def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def main():
    mod=10**9+7
    N=I()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        u,v,w=MI()
        u-=1
        v-=1
        adj[u].append((v,w))
        adj[v].append((u,w))
        
    
    ans=[-1]*N
    import queue
    
    q=queue.Queue()
    q.put(0)
    ans[0]=0
    
    while not q.empty():
        v=q.get()
        for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
    for i in range(N):
        print(ans[i])
    
     def main():
    mod=10**9+7
    N=I()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        u,v,w=MI()
        u-=1
        v-=1
        adj[u].append((v,w))
        adj[v].append((u,w))
        
    
    ans=[-1]*N
    import queue
    
    q=queue.Queue()
    q.put(0)
    ans[0]=0
    
    while not q.empty():
        v=q.get()
        for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
    for i in range(N):
        print(ans[i])
    
     main
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        u,v,w=MI()
        u-=1
        v-=1
        adj[u].append((v,w))
        adj[v].append((u,w))
        
    
    ans=[-1]*N
    import queue
    
    q=queue.Queue()
    q.put(0)
    ans[0]=0
    
    while not q.empty():
        v=q.get()
        for nv,w in adj[v]:
            if ans[nv]==-1:
                if ans[v]==0 and w%2==0:
                    ans[nv]=0
                elif ans[v]==0 and w%2==1:
                    ans[nv]=1
                elif ans[v]==1 and w%2==0:
                    ans[nv]=1
                else:
                    ans[nv]=0
                q.put(nv)
                
    for i in range(N):
        print(ans[i])
    
    

main()
