import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
graph = [{} for _ in range(N)]

for _ in range(N-1):
    u, v, w = mapint()
    graph[u-1][v-1] = w%2
    graph[v-1][u-1] = w%2

from collections import deque
stack = deque([0])

colors = [-1]*N
colors[0] = 0
while stack:
    v = stack.pop()
    for nx in graph[v].keys():
        if colors[nx]==-1:
            w = graph[v][nx]
            colors[nx] = (colors[v]+w)%2
            stack.append(nx)

for a in colors:
    print(a) import sys sys def input(): return sys.stdin.readline().strip() input def mapint(): return map(int, input().split()) mapint sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 N = int(input()) N int(input()) int input() input {} for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) {} graph = [{} for _ in range(N)] graph [{} for _ in range(N)] for _ in range(N-1):
    u, v, w = mapint()
    graph[u-1][v-1] = w%2
    graph[v-1][u-1] = w%2 _ range(N-1) range N-1 N 1 u, v, w = mapint() u mapint() mapint v w graph[u-1][v-1] = w%2 graph[u-1][v-1] [u-1] graph u-1 u 1 v-1 v 1 w%2 w 2 graph[v-1][u-1] = w%2 graph[v-1][u-1] [v-1] graph v-1 v 1 u-1 u 1 w%2 w 2 from collections import deque stack = deque([0]) stack deque([0]) deque [0] 0 colors = [-1]*N colors [-1]*N [-1] -1 N colors[0] = 0 colors[0] colors 0 0 while stack:
    v = stack.pop()
    for nx in graph[v].keys():
        if colors[nx]==-1:
            w = graph[v][nx]
            colors[nx] = (colors[v]+w)%2
            stack.append(nx) stack v = stack.pop() v stack.pop() stack.pop stack pop for nx in graph[v].keys():
        if colors[nx]==-1:
            w = graph[v][nx]
            colors[nx] = (colors[v]+w)%2
            stack.append(nx) nx graph[v].keys() [v].keys [v] graph v keys if colors[nx]==-1:
            w = graph[v][nx]
            colors[nx] = (colors[v]+w)%2
            stack.append(nx) colors[nx]==-1 colors[nx] colors nx -1 w = graph[v][nx] w graph[v][nx] [v] graph v nx colors[nx] = (colors[v]+w)%2 colors[nx] colors nx (colors[v]+w)%2 colors[v]+w colors[v] colors v w 2 stack.append(nx) stack.append stack append nx for a in colors:
    print(a) a colors print(a) print a def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input N = int(input()) int(input()) N w = graph[v][nx] graph[v][nx] w graph = [{} for _ in range(N)] [{} for _ in range(N)] graph u, v, w = mapint() mapint() u def mapint(): return map(int, input().split()) def mapint(): return map(int, input().split()) mapint stack = deque([0]) deque([0]) stack w = mapint() mapint() w v, w = mapint() mapint() v colors = [-1]*N [-1]*N colors v = stack.pop() stack.pop() v
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
graph = [{} for _ in range(N)]

for _ in range(N-1):
    u, v, w = mapint()
    graph[u-1][v-1] = w%2
    graph[v-1][u-1] = w%2

from collections import deque
stack = deque([0])

colors = [-1]*N
colors[0] = 0
while stack:
    v = stack.pop()
    for nx in graph[v].keys():
        if colors[nx]==-1:
            w = graph[v][nx]
            colors[nx] = (colors[v]+w)%2
            stack.append(nx)

for a in colors:
    print(a)