import sys
sys.setrecursionlimit(100000)

class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []
    
    def add_edge(self, v1, v2, dist):
        self.adjacency_dict[v1].append([v2, dist])
        self.adjacency_dict[v2].append([v1, dist])
    
    def next_edges(self, v):
        return self.adjacency_dict[v]

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

graph = Graph()
for i in range(1, N+1):
    graph.add_vertex(i)
for v1, v2, dist in dists:
    graph.add_edge(v1, v2, dist)

def dfs(start, group):
    if visited[start] is not None:
        return
    visited[start] = group
    for v, dist in graph.next_edges(start):
        if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group)

visited = [None]*(N+1)
dfs(1, 0)
for i in visited[1:]:
    print(i) import sys sys sys.setrecursionlimit(100000) sys.setrecursionlimit sys setrecursionlimit 100000 class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []
    
    def add_edge(self, v1, v2, dist):
        self.adjacency_dict[v1].append([v2, dist])
        self.adjacency_dict[v2].append([v1, dist])
    
    def next_edges(self, v):
        return self.adjacency_dict[v] Graph def __init__(self):
        self.adjacency_dict = {}

     __init__ self.adjacency_dict = {} self.adjacency_dict self adjacency_dict {} self self def add_vertex(self, v):
        self.adjacency_dict[v] = []
    
     add_vertex self.adjacency_dict[v] = [] self.adjacency_dict[v] self.adjacency_dict self adjacency_dict v [] self self v v def add_edge(self, v1, v2, dist):
        self.adjacency_dict[v1].append([v2, dist])
        self.adjacency_dict[v2].append([v1, dist])
    
     add_edge self.adjacency_dict[v1].append([v2, dist]) self.adjacency_dict[v1].append self.adjacency_dict[v1] self.adjacency_dict self adjacency_dict v1 append [v2, dist] v2 dist self.adjacency_dict[v2].append([v1, dist]) self.adjacency_dict[v2].append self.adjacency_dict[v2] self.adjacency_dict self adjacency_dict v2 append [v1, dist] v1 dist self self v1 v1 v2 v2 dist dist def next_edges(self, v):
        return self.adjacency_dict[v] next_edges return self.adjacency_dict[v] self.adjacency_dict[v] self.adjacency_dict self adjacency_dict v self self v v 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 dists = [list(map(int, input().split())) for _ in range(N-1)] dists [list(map(int, input().split())) for _ in range(N-1)] graph = Graph() graph Graph() Graph for i in range(1, N+1):
    graph.add_vertex(i) i range(1, N+1) range 1 N+1 N 1 graph.add_vertex(i) graph.add_vertex graph add_vertex i for v1, v2, dist in dists:
    graph.add_edge(v1, v2, dist) v1 v2 dist dists graph.add_edge(v1, v2, dist) graph.add_edge graph add_edge v1 v2 dist def dfs(start, group):
    if visited[start] is not None:
        return
    visited[start] = group
    for v, dist in graph.next_edges(start):
        if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group) dfs if visited[start] is not None:
        return
     visited[start] is not None visited[start] visited start None return visited[start] = group visited[start] visited start group for v, dist in graph.next_edges(start):
        if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group) v dist graph.next_edges(start) graph.next_edges graph next_edges start if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group) dist % 2 == 0 dist % 2 dist 2 0 dfs(v, group) dfs v group dfs(v, 1-group) dfs v 1-group 1 group start start group group visited = [None]*(N+1) visited [None]*(N+1) [None] None N+1 N 1 dfs(1, 0) dfs 1 0 for i in visited[1:]:
    print(i) i visited[1:] visited 1: 1 print(i) print i class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []
    
    def add_edge(self, v1, v2, dist):
        self.adjacency_dict[v1].append([v2, dist])
        self.adjacency_dict[v2].append([v1, dist])
    
    def next_edges(self, v):
        return self.adjacency_dict[v] class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []
    
    def add_edge(self, v1, v2, dist):
        self.adjacency_dict[v1].append([v2, dist])
        self.adjacency_dict[v2].append([v1, dist])
    
    def next_edges(self, v):
        return self.adjacency_dict[v] Graph dists = [list(map(int, input().split())) for _ in range(N-1)] [list(map(int, input().split())) for _ in range(N-1)] dists def dfs(start, group):
    if visited[start] is not None:
        return
    visited[start] = group
    for v, dist in graph.next_edges(start):
        if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group) def dfs(start, group):
    if visited[start] is not None:
        return
    visited[start] = group
    for v, dist in graph.next_edges(start):
        if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group) dfs graph = Graph() Graph() graph N = int(input()) int(input()) N visited = [None]*(N+1) [None]*(N+1) visited
import sys
sys.setrecursionlimit(100000)

class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []
    
    def add_edge(self, v1, v2, dist):
        self.adjacency_dict[v1].append([v2, dist])
        self.adjacency_dict[v2].append([v1, dist])
    
    def next_edges(self, v):
        return self.adjacency_dict[v]

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

graph = Graph()
for i in range(1, N+1):
    graph.add_vertex(i)
for v1, v2, dist in dists:
    graph.add_edge(v1, v2, dist)

def dfs(start, group):
    if visited[start] is not None:
        return
    visited[start] = group
    for v, dist in graph.next_edges(start):
        if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group)

visited = [None]*(N+1)
dfs(1, 0)
for i in visited[1:]:
    print(i)