def INT():
    return int(input())

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

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

from collections import deque

N = INT()
Tree = [[] for _ in range(N)]

for _ in range(N - 1):
    u, v, w = MI()
    Tree[u - 1].append((v - 1, w))
    Tree[v - 1].append((u - 1, w))
    
color = [0] * N
queue = deque([0])
visited = [False] * N

while queue:
    q = queue.popleft()
    visited[q] = True
    
    for t in Tree[q]:
        if not visited[t[0]]:
            if t[1] % 2 == 0:
                color[t[0]] = color[q]
                
            else:
                if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
            queue.append(t[0])
        
for c in color:
    print(c) def INT():
    return int(input()) INT return int(input()) int(input()) int input() input def MI():
    return map(int, input().split()) MI return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def LI():
    return list(map(int, input().split())) LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split from collections import deque N = INT() N INT() INT [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] Tree = [[] for _ in range(N)] Tree [[] for _ in range(N)] for _ in range(N - 1):
    u, v, w = MI()
    Tree[u - 1].append((v - 1, w))
    Tree[v - 1].append((u - 1, w))
     _ range(N - 1) range N - 1 N 1 u, v, w = MI() u MI() MI v w Tree[u - 1].append((v - 1, w)) [u - 1].append [u - 1] Tree u - 1 u 1 append (v - 1, w) v - 1 v 1 w Tree[v - 1].append((u - 1, w)) [v - 1].append [v - 1] Tree v - 1 v 1 append (u - 1, w) u - 1 u 1 w color = [0] * N color [0] * N [0] 0 N queue = deque([0]) queue deque([0]) deque [0] 0 visited = [False] * N visited [False] * N [False] False N while queue:
    q = queue.popleft()
    visited[q] = True
    
    for t in Tree[q]:
        if not visited[t[0]]:
            if t[1] % 2 == 0:
                color[t[0]] = color[q]
                
            else:
                if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
            queue.append(t[0])
         queue q = queue.popleft() q queue.popleft() queue.popleft queue popleft visited[q] = True visited[q] visited q True for t in Tree[q]:
        if not visited[t[0]]:
            if t[1] % 2 == 0:
                color[t[0]] = color[q]
                
            else:
                if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
            queue.append(t[0])
         t Tree[q] Tree q if not visited[t[0]]:
            if t[1] % 2 == 0:
                color[t[0]] = color[q]
                
            else:
                if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
            queue.append(t[0])
         not visited[t[0]] visited[t[0]] visited t[0] t 0 if t[1] % 2 == 0:
                color[t[0]] = color[q]
                
            else:
                if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
             t[1] % 2 == 0 t[1] % 2 t[1] t 1 2 0 color[t[0]] = color[q] color[t[0]] color t[0] t 0 color[q] color q if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
             color[q] == 0 color[q] color q 0 color[t[0]] = 1 color[t[0]] color t[0] t 0 1 color[t[0]] = 0 color[t[0]] color t[0] t 0 0 queue.append(t[0]) queue.append queue append t[0] t 0 for c in color:
    print(c) c color print(c) print c queue = deque([0]) deque([0]) queue color = [0] * N [0] * N color v, w = MI() MI() v u, v, w = MI() MI() u Tree = [[] for _ in range(N)] [[] for _ in range(N)] Tree w = MI() MI() w visited = [False] * N [False] * N visited N = INT() INT() N def INT():
    return int(input()) def INT():
    return int(input()) INT q = queue.popleft() queue.popleft() q 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 INT():
    return int(input())

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

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

from collections import deque

N = INT()
Tree = [[] for _ in range(N)]

for _ in range(N - 1):
    u, v, w = MI()
    Tree[u - 1].append((v - 1, w))
    Tree[v - 1].append((u - 1, w))
    
color = [0] * N
queue = deque([0])
visited = [False] * N

while queue:
    q = queue.popleft()
    visited[q] = True
    
    for t in Tree[q]:
        if not visited[t[0]]:
            if t[1] % 2 == 0:
                color[t[0]] = color[q]
                
            else:
                if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
            queue.append(t[0])
        
for c in color:
    print(c)