from collections import deque

N = int(input())
e = [[] for i in range(N)]
for i in range(1, N):
    u, v, w = map(int, input().split())
    e[u-1].append((v-1, w))
    e[v-1].append((u-1, w))
l = [-1 for i in range(N)]

q = deque()
l[0] = 0
q.append(0)
while (q):
    u = q.pop()
    for v, w in e[u]:
        if l[v] >= 0:
            continue
        if w % 2 == 0:
            l[v] = l[u]
        else:
            l[v] = 1 - l[u]
        q.append(v)

for col in l:
    print(col) from collections import deque N = int(input()) N int(input()) int input() input [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] e = [[] for i in range(N)] e [[] for i in range(N)] for i in range(1, N):
    u, v, w = map(int, input().split())
    e[u-1].append((v-1, w))
    e[v-1].append((u-1, w)) i range(1, N) range 1 N u, v, w = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v w e[u-1].append((v-1, w)) [u-1].append [u-1] e u-1 u 1 append (v-1, w) v-1 v 1 w e[v-1].append((u-1, w)) [v-1].append [v-1] e v-1 v 1 append (u-1, w) u-1 u 1 w -1 for i in range(N) for i in range(N) i range(N) range N for i in range(N) -1 l = [-1 for i in range(N)] l [-1 for i in range(N)] q = deque() q deque() deque l[0] = 0 l[0] l 0 0 q.append(0) q.append q append 0 while (q):
    u = q.pop()
    for v, w in e[u]:
        if l[v] >= 0:
            continue
        if w % 2 == 0:
            l[v] = l[u]
        else:
            l[v] = 1 - l[u]
        q.append(v) q u = q.pop() u q.pop() q.pop q pop for v, w in e[u]:
        if l[v] >= 0:
            continue
        if w % 2 == 0:
            l[v] = l[u]
        else:
            l[v] = 1 - l[u]
        q.append(v) v w e[u] e u if l[v] >= 0:
            continue
         l[v] >= 0 l[v] l v 0 continue if w % 2 == 0:
            l[v] = l[u]
        else:
            l[v] = 1 - l[u]
         w % 2 == 0 w % 2 w 2 0 l[v] = l[u] l[v] l v l[u] l u l[v] = 1 - l[u] l[v] l v 1 - l[u] 1 l[u] l u q.append(v) q.append q append v for col in l:
    print(col) col l print(col) print col u, v, w = map(int, input().split()) map(int, input().split()) u N = int(input()) int(input()) N e = [[] for i in range(N)] [[] for i in range(N)] e q = deque() deque() q u = q.pop() q.pop() u v, w = map(int, input().split()) map(int, input().split()) v l = [-1 for i in range(N)] [-1 for i in range(N)] l w = map(int, input().split()) map(int, input().split()) w
from collections import deque

N = int(input())
e = [[] for i in range(N)]
for i in range(1, N):
    u, v, w = map(int, input().split())
    e[u-1].append((v-1, w))
    e[v-1].append((u-1, w))
l = [-1 for i in range(N)]

q = deque()
l[0] = 0
q.append(0)
while (q):
    u = q.pop()
    for v, w in e[u]:
        if l[v] >= 0:
            continue
        if w % 2 == 0:
            l[v] = l[u]
        else:
            l[v] = 1 - l[u]
        q.append(v)

for col in l:
    print(col)
