import sys
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, sys.stdin.readline().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

done = {}
todo = [(0, 0, 0)]
while todo:
    i, c, d = todo.pop()
    for ni, dd in G[i]:
        if ni in done:
            continue
        nd = d + dd
        nc = nd % 2
        todo.append((ni, nc, nd))
    done[i] = c

for i in range(N):
    print(done[i]) import sys sys 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) [] G = [[] for _ in range(N)] G [[] for _ in range(N)] for _ in range(N - 1):
    u, v, w = map(int, sys.stdin.readline().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w)) _ range(N - 1) range N - 1 N 1 u, v, w = map(int, sys.stdin.readline().split()) u map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split v w u -= 1 u 1 v -= 1 v 1 G[u].append((v, w)) [u].append [u] G u append (v, w) v w G[v].append((u, w)) [v].append [v] G v append (u, w) u w done = {} done {} todo = [(0, 0, 0)] todo [(0, 0, 0)] (0, 0, 0) 0 0 0 while todo:
    i, c, d = todo.pop()
    for ni, dd in G[i]:
        if ni in done:
            continue
        nd = d + dd
        nc = nd % 2
        todo.append((ni, nc, nd))
    done[i] = c todo i, c, d = todo.pop() i todo.pop() todo.pop todo pop c d for ni, dd in G[i]:
        if ni in done:
            continue
        nd = d + dd
        nc = nd % 2
        todo.append((ni, nc, nd))
     ni dd G[i] G i if ni in done:
            continue
         ni in done ni done continue nd = d + dd nd d + dd d dd nc = nd % 2 nc nd % 2 nd 2 todo.append((ni, nc, nd)) todo.append todo append (ni, nc, nd) ni nc nd done[i] = c done[i] done i c for i in range(N):
    print(done[i]) i range(N) range N print(done[i]) print done[i] done i w = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) w done = {} {} done G = [[] for _ in range(N)] [[] for _ in range(N)] G v -= 1 1 v nc = nd % 2 nd % 2 nc c, d = todo.pop() todo.pop() c N = int(input()) int(input()) N i, c, d = todo.pop() todo.pop() i nd = d + dd d + dd nd d = todo.pop() todo.pop() d todo = [(0, 0, 0)] [(0, 0, 0)] todo u, v, w = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) u u -= 1 1 u v, w = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) v
import sys
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, sys.stdin.readline().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))

done = {}
todo = [(0, 0, 0)]
while todo:
    i, c, d = todo.pop()
    for ni, dd in G[i]:
        if ni in done:
            continue
        nd = d + dd
        nc = nd % 2
        todo.append((ni, nc, nd))
    done[i] = c

for i in range(N):
    print(done[i])