import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)

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

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(*color, sep="\n") import sys sys input=sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline 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) [] edge = [[] for _ in range(N)] edge [[] for _ in range(N)] for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w)) i range(N-1) range N-1 N 1 v1, v2, w = map(int, input().split()) v1 map(int, input().split()) map int input().split() ().split () input split v2 w edge[v1-1].append((v2-1, w)) [v1-1].append [v1-1] edge v1-1 v1 1 append (v2-1, w) v2-1 v2 1 w edge[v2-1].append((v1-1, w)) [v2-1].append [v2-1] edge v2-1 v2 1 append (v1-1, w) v1-1 v1 1 w -1 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) -1 color = [-1 for _ in range(N)] color [-1 for _ in range(N)] color[0] = 1 color[0] color 0 1 def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v) dfs for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v) v w edge[x] edge x if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v) color[v] == -1 color[v] color v -1 color[v] = (w + color[x])%2 color[v] color v (w + color[x])%2 w + color[x] w color[x] color x 2 dfs(v) dfs v x x dfs(0) dfs 0 print(*color, sep="\n") print *color color sep="\n" sep "\n" v1, v2, w = map(int, input().split()) map(int, input().split()) v1 w = map(int, input().split()) map(int, input().split()) w N = int(input()) int(input()) N edge = [[] for _ in range(N)] [[] for _ in range(N)] edge color = [-1 for _ in range(N)] [-1 for _ in range(N)] color input=sys.stdin.buffer.readline sys.stdin.buffer.readline input v2, w = map(int, input().split()) map(int, input().split()) v2 def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v) def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v) dfs
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)

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

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(*color, sep="\n")