from collections import deque
n = int(input())
route = [[] for i in range(n+1)]
for i in range(n-1):
    u , v , w = map(int,input().split())
    route[u].append((v,w))
    route[v].append((u,w))

ans = [-1 for i in range(n+1)]

d = deque()
d.append(1)
ans[1] = 0
while d:
    now = d.popleft()
    for i , j in route[now]:
        if ans[i] == -1:
            if j % 2 == 0:
                ans[i] = ans[now]
            elif j % 2 == 1:
                ans[i] = (ans[now]+1)%2
            d.append(i)

for i in range(1,n+1):
    print(ans[i]) from collections import deque n = int(input()) n int(input()) int input() input [] for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) [] route = [[] for i in range(n+1)] route [[] for i in range(n+1)] for i in range(n-1):
    u , v , w = map(int,input().split())
    route[u].append((v,w))
    route[v].append((u,w)) 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 route[u].append((v,w)) [u].append [u] route u append (v,w) v w route[v].append((u,w)) [v].append [v] route v append (u,w) u w -1 for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) -1 ans = [-1 for i in range(n+1)] ans [-1 for i in range(n+1)] d = deque() d deque() deque d.append(1) d.append d append 1 ans[1] = 0 ans[1] ans 1 0 while d:
    now = d.popleft()
    for i , j in route[now]:
        if ans[i] == -1:
            if j % 2 == 0:
                ans[i] = ans[now]
            elif j % 2 == 1:
                ans[i] = (ans[now]+1)%2
            d.append(i) d now = d.popleft() now d.popleft() d.popleft d popleft for i , j in route[now]:
        if ans[i] == -1:
            if j % 2 == 0:
                ans[i] = ans[now]
            elif j % 2 == 1:
                ans[i] = (ans[now]+1)%2
            d.append(i) i j route[now] route now if ans[i] == -1:
            if j % 2 == 0:
                ans[i] = ans[now]
            elif j % 2 == 1:
                ans[i] = (ans[now]+1)%2
            d.append(i) ans[i] == -1 ans[i] ans i -1 if j % 2 == 0:
                ans[i] = ans[now]
            elif j % 2 == 1:
                ans[i] = (ans[now]+1)%2
             j % 2 == 0 j % 2 j 2 0 ans[i] = ans[now] ans[i] ans i ans[now] ans now elif j % 2 == 1:
                ans[i] = (ans[now]+1)%2
             j % 2 == 1 j % 2 j 2 1 ans[i] = (ans[now]+1)%2 ans[i] ans i (ans[now]+1)%2 ans[now]+1 ans[now] ans now 1 2 d.append(i) d.append d append i for i in range(1,n+1):
    print(ans[i]) i range(1,n+1) range 1 n+1 n 1 print(ans[i]) print ans[i] ans i d = deque() deque() d u , v , w = map(int,input().split()) map(int,input().split()) u ans = [-1 for i in range(n+1)] [-1 for i in range(n+1)] ans n = int(input()) int(input()) n w = map(int,input().split()) map(int,input().split()) w now = d.popleft() d.popleft() now route = [[] for i in range(n+1)] [[] for i in range(n+1)] route v , w = map(int,input().split()) map(int,input().split()) v
from collections import deque
n = int(input())
route = [[] for i in range(n+1)]
for i in range(n-1):
    u , v , w = map(int,input().split())
    route[u].append((v,w))
    route[v].append((u,w))

ans = [-1 for i in range(n+1)]

d = deque()
d.append(1)
ans[1] = 0
while d:
    now = d.popleft()
    for i , j in route[now]:
        if ans[i] == -1:
            if j % 2 == 0:
                ans[i] = ans[now]
            elif j % 2 == 1:
                ans[i] = (ans[now]+1)%2
            d.append(i)

for i in range(1,n+1):
    print(ans[i])