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

def dfs(d, v, p):
    if (d & 1):
        C[v] = 1
    for w, u in E[v]:
        if u == p:
            continue
        dfs(d ^ w, u, v)

N = int(input())
C = [0] * N
E = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    E[u].append((w % 2, v))
    E[v].append((w % 2, u))
dfs(0, 0, -1)
print(*C, sep='\n') import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def dfs(d, v, p):
    if (d & 1):
        C[v] = 1
    for w, u in E[v]:
        if u == p:
            continue
        dfs(d ^ w, u, v) dfs if (d & 1):
        C[v] = 1
     d & 1 d 1 C[v] = 1 C[v] C v 1 for w, u in E[v]:
        if u == p:
            continue
        dfs(d ^ w, u, v) w u E[v] E v if u == p:
            continue
         u == p u p continue dfs(d ^ w, u, v) dfs d ^ w d w u v d d v v p p N = int(input()) N int(input()) int input() input C = [0] * N C [0] * N [0] 0 N [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] E = [[] for _ in range(N)] E [[] for _ in range(N)] for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    E[u].append((w % 2, v))
    E[v].append((w % 2, u)) i 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 E[u].append((w % 2, v)) [u].append [u] E u append (w % 2, v) w % 2 w 2 v E[v].append((w % 2, u)) [v].append [v] E v append (w % 2, u) w % 2 w 2 u dfs(0, 0, -1) dfs 0 0 -1 print(*C, sep='\n') print *C C sep='\n' sep '\n' C = [0] * N [0] * N C w = map(int, input().split()) map(int, input().split()) w input = sys.stdin.readline sys.stdin.readline input def dfs(d, v, p):
    if (d & 1):
        C[v] = 1
    for w, u in E[v]:
        if u == p:
            continue
        dfs(d ^ w, u, v) def dfs(d, v, p):
    if (d & 1):
        C[v] = 1
    for w, u in E[v]:
        if u == p:
            continue
        dfs(d ^ w, u, v) dfs E = [[] for _ in range(N)] [[] for _ in range(N)] E u, v, w = map(int, input().split()) map(int, input().split()) u N = int(input()) int(input()) N u -= 1 1 u v, w = map(int, input().split()) map(int, input().split()) v v -= 1 1 v
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def dfs(d, v, p):
    if (d & 1):
        C[v] = 1
    for w, u in E[v]:
        if u == p:
            continue
        dfs(d ^ w, u, v)

N = int(input())
C = [0] * N
E = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    E[u].append((w % 2, v))
    E[v].append((w % 2, u))
dfs(0, 0, -1)
print(*C, sep='\n')