from collections import deque

N = int(input())


vlist = [[] for _ in range(N)]

for i in range(N-1):
    a,b,w = map(int, input().split())
    a -= 1
    b -= 1
    vlist[a].append((b,w))
    vlist[b].append((a,w))

ans = [-1] * N
q = deque()

ans[0] = 0
q.append(0)

while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
    
for i in ans:
    print(i)


 from collections import deque 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) [] vlist = [[] for _ in range(N)] vlist [[] for _ in range(N)] for i in range(N-1):
    a,b,w = map(int, input().split())
    a -= 1
    b -= 1
    vlist[a].append((b,w))
    vlist[b].append((a,w)) i range(N-1) range N-1 N 1 a,b,w = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b w a -= 1 a 1 b -= 1 b 1 vlist[a].append((b,w)) [a].append [a] vlist a append (b,w) b w vlist[b].append((a,w)) [b].append [b] vlist b append (a,w) a w ans = [-1] * N ans [-1] * N [-1] -1 N q = deque() q deque() deque ans[0] = 0 ans[0] ans 0 0 q.append(0) q.append q append 0 while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
     q new = q.popleft() new q.popleft() q.popleft q popleft for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
     node weight vlist[new] vlist new if ans[node] != -1:
            continue
         ans[node] != -1 ans[node] ans node -1 continue ans[node] = (ans[new] + weight) % 2 ans[node] ans node (ans[new] + weight) % 2 ans[new] + weight ans[new] ans new weight 2 q.append(node) q.append q append node for i in ans:
    print(i) i ans print(i) print i q = deque() deque() q vlist = [[] for _ in range(N)] [[] for _ in range(N)] vlist N = int(input()) int(input()) N b -= 1 1 b a,b,w = map(int, input().split()) map(int, input().split()) a b,w = map(int, input().split()) map(int, input().split()) b new = q.popleft() q.popleft() new ans = [-1] * N [-1] * N ans a -= 1 1 a w = map(int, input().split()) map(int, input().split()) w
from collections import deque

N = int(input())


vlist = [[] for _ in range(N)]

for i in range(N-1):
    a,b,w = map(int, input().split())
    a -= 1
    b -= 1
    vlist[a].append((b,w))
    vlist[b].append((a,w))

ans = [-1] * N
q = deque()

ans[0] = 0
q.append(0)

while q:
    new = q.popleft()
    for node, weight in vlist[new]:
        if ans[node] != -1:
            continue
        ans[node] = (ans[new] + weight) % 2
        q.append(node)
    
for i in ans:
    print(i)



