from collections import deque

def bfs(start, g, visited):
    q = deque([start])
    visited[start] = 0
    while q:
        curr_node = q.popleft()
        for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node)


n = int(input())
gl = [ [] for _ in range(n+1)]
for _ in range(n-1):
    u,v,w = map(int, input().split())
    gl[u].append((v,w))
    gl[v].append((u,w))
visited = [-1] * (n+1)
bfs(1, gl, visited)

for v in visited[1:]:
    if v%2 == 0: print(0)
    else: print(1) from collections import deque def bfs(start, g, visited):
    q = deque([start])
    visited[start] = 0
    while q:
        curr_node = q.popleft()
        for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node) bfs q = deque([start]) q deque([start]) deque [start] start visited[start] = 0 visited[start] visited start 0 while q:
        curr_node = q.popleft()
        for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node) q curr_node = q.popleft() curr_node q.popleft() q.popleft q popleft for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node) next_node w g[curr_node] g curr_node if visited[next_node] >= 0: continue
             visited[next_node] >= 0 visited[next_node] visited next_node 0 visited[next_node] = (visited[curr_node] + w)%2 visited[next_node] visited next_node (visited[curr_node] + w)%2 visited[curr_node] + w visited[curr_node] visited curr_node w 2 q.append(next_node) q.append q append next_node start start g g visited visited n = int(input()) n int(input()) int input() input [] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [] gl = [ [] for _ in range(n+1)] gl [ [] for _ in range(n+1)] for _ in range(n-1):
    u,v,w = map(int, input().split())
    gl[u].append((v,w))
    gl[v].append((u,w)) _ range(n-1) range n-1 n 1 u,v,w = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v w gl[u].append((v,w)) [u].append [u] gl u append (v,w) v w gl[v].append((u,w)) [v].append [v] gl v append (u,w) u w visited = [-1] * (n+1) visited [-1] * (n+1) [-1] -1 n+1 n 1 bfs(1, gl, visited) bfs 1 gl visited for v in visited[1:]:
    if v%2 == 0: print(0)
    else: print(1) v visited[1:] visited 1: 1 if v%2 == 0: print(0)
    else: print(1) v%2 == 0 v%2 v 2 0 v,w = map(int, input().split()) map(int, input().split()) v def bfs(start, g, visited):
    q = deque([start])
    visited[start] = 0
    while q:
        curr_node = q.popleft()
        for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node) def bfs(start, g, visited):
    q = deque([start])
    visited[start] = 0
    while q:
        curr_node = q.popleft()
        for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node) bfs n = int(input()) int(input()) n gl = [ [] for _ in range(n+1)] [ [] for _ in range(n+1)] gl w = map(int, input().split()) map(int, input().split()) w visited = [-1] * (n+1) [-1] * (n+1) visited u,v,w = map(int, input().split()) map(int, input().split()) u
from collections import deque

def bfs(start, g, visited):
    q = deque([start])
    visited[start] = 0
    while q:
        curr_node = q.popleft()
        for next_node, w in g[curr_node]:
            if visited[next_node] >= 0: continue
            visited[next_node] = (visited[curr_node] + w)%2
            q.append(next_node)


n = int(input())
gl = [ [] for _ in range(n+1)]
for _ in range(n-1):
    u,v,w = map(int, input().split())
    gl[u].append((v,w))
    gl[v].append((u,w))
visited = [-1] * (n+1)
bfs(1, gl, visited)

for v in visited[1:]:
    if v%2 == 0: print(0)
    else: print(1)