from collections import deque

N = int(input())
conn = [[] for _ in range(N + 1)]
for i in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    conn[u].append([v, w])
    conn[v].append([u, w])

q = deque([1])
d = [-1]* (N + 1)
d[1] = 0
while q:
    u = q.popleft()
    for e in conn[u]:
        v, w = e[0], e[1]
        if d[v] == -1:
            d[v] = d[u] + w
            q.append(v)

for v in range(1, N + 1):
    print(d[v] % 2) from collections import deque N = int(input()) N int(input()) int input() input [] for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) [] conn = [[] for _ in range(N + 1)] conn [[] for _ in range(N + 1)] for i in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    conn[u].append([v, w])
    conn[v].append([u, w]) i range(N - 1) range N - 1 N 1 int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x u, v, w = [int(x) for x in input().split()] u [int(x) for x in input().split()] v w conn[u].append([v, w]) [u].append [u] conn u append [v, w] v w conn[v].append([u, w]) [v].append [v] conn v append [u, w] u w q = deque([1]) q deque([1]) deque [1] 1 d = [-1]* (N + 1) d [-1]* (N + 1) [-1] -1 N + 1 N 1 d[1] = 0 d[1] d 1 0 while q:
    u = q.popleft()
    for e in conn[u]:
        v, w = e[0], e[1]
        if d[v] == -1:
            d[v] = d[u] + w
            q.append(v) q u = q.popleft() u q.popleft() q.popleft q popleft for e in conn[u]:
        v, w = e[0], e[1]
        if d[v] == -1:
            d[v] = d[u] + w
            q.append(v) e conn[u] conn u v, w = e[0], e[1] v e[0] e 0 w e[1] e 1 if d[v] == -1:
            d[v] = d[u] + w
            q.append(v) d[v] == -1 d[v] d v -1 d[v] = d[u] + w d[v] d v d[u] + w d[u] d u w q.append(v) q.append q append v for v in range(1, N + 1):
    print(d[v] % 2) v range(1, N + 1) range 1 N + 1 N 1 print(d[v] % 2) print d[v] % 2 d[v] d v 2 u, v, w = [int(x) for x in input().split()] [int(x) for x in input().split()] u d = [-1]* (N + 1) [-1]* (N + 1) d conn = [[] for _ in range(N + 1)] [[] for _ in range(N + 1)] conn q = deque([1]) deque([1]) q v, w = e[0], e[1] e[0] v v, w = [int(x) for x in input().split()] [int(x) for x in input().split()] v w = [int(x) for x in input().split()] [int(x) for x in input().split()] w u = q.popleft() q.popleft() u N = int(input()) int(input()) N w = e[0], e[1] e[1] w
from collections import deque

N = int(input())
conn = [[] for _ in range(N + 1)]
for i in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    conn[u].append([v, w])
    conn[v].append([u, w])

q = deque([1])
d = [-1]* (N + 1)
d[1] = 0
while q:
    u = q.popleft()
    for e in conn[u]:
        v, w = e[0], e[1]
        if d[v] == -1:
            d[v] = d[u] + w
            q.append(v)

for v in range(1, N + 1):
    print(d[v] % 2)