import sys
sys.setrecursionlimit(10**7)
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))
ans = [-1] * n
def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u)

dfs()
print(*ans, sep='\n') import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 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) [] to = [[] for _ in range(n)] to [[] for _ in range(n)] for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[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 u -= 1 u 1 v -= 1 v 1 to[u].append((v, w)) [u].append [u] to u append (v, w) v w to[v].append((u, w)) [v].append [v] to v append (u, w) u w ans = [-1] * n ans [-1] * n [-1] -1 n def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u) dfs ans[u] = c ans[u] ans u c for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u) v w to[u] to u if v == parent:
            continue
         v == parent v parent continue dfs(v, (c + w) & 1, u) dfs v (c + w) & 1 c + w c w 1 u u=0 u 0 c=0 c 0 parent=-1 parent -1 dfs() dfs print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' n = int(input()) int(input()) n to = [[] for _ in range(n)] [[] for _ in range(n)] to ans = [-1] * n [-1] * n ans w = map(int, input().split()) map(int, input().split()) w def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u) def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u) dfs u -= 1 1 u v -= 1 1 v v, w = map(int, input().split()) map(int, input().split()) v u, v, w = map(int, input().split()) map(int, input().split()) u
import sys
sys.setrecursionlimit(10**7)
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))
ans = [-1] * n
def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u)

dfs()
print(*ans, sep='\n')
