#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 08:50:44 2020

@author: naoki
"""
from collections import deque

N = int(input())
uvws = [list(map(int, input().split())) for _ in range(N-1)]

routes = [[] for _ in range(N)]
for uvw in uvws:
    u = uvw[0]-1
    v = uvw[1]-1
    w = uvw[2]
    
    routes[u].append([v,w])
    routes[v].append([u,w])
    
    
colors = [-1 for _ in range(N)]
todo = deque()
todo.append(0)
colors[0] = 0


while len(todo)>0:
    checking = todo.pop()
    for route in routes[checking]:
        destination = route[0]
        weight = route[1]
        
        if colors[destination] == -1:
            if weight%2 == 0:
                colors[destination] = colors[checking]
            else:
                colors[destination] = 1 - colors[checking]
            todo.append(destination)

for i in range(N):
    print(colors[i]) """
Created on Sat Aug 15 08:50:44 2020

@author: naoki
""" from collections import deque N = int(input()) N int(input()) int input() input list(map(int, input().split())) for _ in range(N-1) for _ in range(N-1) _ range(N-1) range N-1 N 1 for _ in range(N-1) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split uvws = [list(map(int, input().split())) for _ in range(N-1)] uvws [list(map(int, input().split())) for _ in range(N-1)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] routes = [[] for _ in range(N)] routes [[] for _ in range(N)] for uvw in uvws:
    u = uvw[0]-1
    v = uvw[1]-1
    w = uvw[2]
    
    routes[u].append([v,w])
    routes[v].append([u,w])
    
     uvw uvws u = uvw[0]-1 u uvw[0]-1 uvw[0] uvw 0 1 v = uvw[1]-1 v uvw[1]-1 uvw[1] uvw 1 1 w = uvw[2] w uvw[2] uvw 2 routes[u].append([v,w]) [u].append [u] routes u append [v,w] v w routes[v].append([u,w]) [v].append [v] routes v append [u,w] u w -1 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) -1 colors = [-1 for _ in range(N)] colors [-1 for _ in range(N)] todo = deque() todo deque() deque todo.append(0) todo.append todo append 0 colors[0] = 0 colors[0] colors 0 0 while len(todo)>0:
    checking = todo.pop()
    for route in routes[checking]:
        destination = route[0]
        weight = route[1]
        
        if colors[destination] == -1:
            if weight%2 == 0:
                colors[destination] = colors[checking]
            else:
                colors[destination] = 1 - colors[checking]
            todo.append(destination) len(todo)>0 len(todo) len todo 0 checking = todo.pop() checking todo.pop() todo.pop todo pop for route in routes[checking]:
        destination = route[0]
        weight = route[1]
        
        if colors[destination] == -1:
            if weight%2 == 0:
                colors[destination] = colors[checking]
            else:
                colors[destination] = 1 - colors[checking]
            todo.append(destination) route routes[checking] routes checking destination = route[0] destination route[0] route 0 weight = route[1] weight route[1] route 1 if colors[destination] == -1:
            if weight%2 == 0:
                colors[destination] = colors[checking]
            else:
                colors[destination] = 1 - colors[checking]
            todo.append(destination) colors[destination] == -1 colors[destination] colors destination -1 if weight%2 == 0:
                colors[destination] = colors[checking]
            else:
                colors[destination] = 1 - colors[checking]
             weight%2 == 0 weight%2 weight 2 0 colors[destination] = colors[checking] colors[destination] colors destination colors[checking] colors checking colors[destination] = 1 - colors[checking] colors[destination] colors destination 1 - colors[checking] 1 colors[checking] colors checking todo.append(destination) todo.append todo append destination for i in range(N):
    print(colors[i]) i range(N) range N print(colors[i]) print colors[i] colors i routes = [[] for _ in range(N)] [[] for _ in range(N)] routes checking = todo.pop() todo.pop() checking colors = [-1 for _ in range(N)] [-1 for _ in range(N)] colors todo = deque() deque() todo N = int(input()) int(input()) N destination = route[0] route[0] destination uvws = [list(map(int, input().split())) for _ in range(N-1)] [list(map(int, input().split())) for _ in range(N-1)] uvws u = uvw[0]-1 uvw[0]-1 u w = uvw[2] uvw[2] w weight = route[1] route[1] weight v = uvw[1]-1 uvw[1]-1 v
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 08:50:44 2020

@author: naoki
"""
from collections import deque

N = int(input())
uvws = [list(map(int, input().split())) for _ in range(N-1)]

routes = [[] for _ in range(N)]
for uvw in uvws:
    u = uvw[0]-1
    v = uvw[1]-1
    w = uvw[2]
    
    routes[u].append([v,w])
    routes[v].append([u,w])
    
    
colors = [-1 for _ in range(N)]
todo = deque()
todo.append(0)
colors[0] = 0


while len(todo)>0:
    checking = todo.pop()
    for route in routes[checking]:
        destination = route[0]
        weight = route[1]
        
        if colors[destination] == -1:
            if weight%2 == 0:
                colors[destination] = colors[checking]
            else:
                colors[destination] = 1 - colors[checking]
            todo.append(destination)

for i in range(N):
    print(colors[i])