from collections import deque
N = int(input())
T = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u, v, w = u-1, v-1, w % 2
    T[u].append([v, w])
    T[v].append([u, w])

Ans = [-1]*N
P = deque([0])
Ans[0] = 0
while(len(P) > 0):
    a = P.popleft()
    for i in T[a]:
        if Ans[i[0]] == -1:
            if i[1] == 0:
                Ans[i[0]] = Ans[a]
            else:
                Ans[i[0]] = (Ans[a] + 1) % 2
            P.append(i[0])
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) [] T = [[] for _ in range(N)] T [[] for _ in range(N)] for i in range(N-1):
    u, v, w = map(int, input().split())
    u, v, w = u-1, v-1, w % 2
    T[u].append([v, w])
    T[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 u, v, w = u-1, v-1, w % 2 u u-1 u 1 v v-1 v 1 w w % 2 w 2 T[u].append([v, w]) [u].append [u] T u append [v, w] v w T[v].append([u, w]) [v].append [v] T v append [u, w] u w Ans = [-1]*N Ans [-1]*N [-1] -1 N P = deque([0]) P deque([0]) deque [0] 0 Ans[0] = 0 Ans[0] Ans 0 0 while(len(P) > 0):
    a = P.popleft()
    for i in T[a]:
        if Ans[i[0]] == -1:
            if i[1] == 0:
                Ans[i[0]] = Ans[a]
            else:
                Ans[i[0]] = (Ans[a] + 1) % 2
            P.append(i[0]) len(P) > 0 len(P) len P 0 a = P.popleft() a P.popleft() P.popleft P popleft for i in T[a]:
        if Ans[i[0]] == -1:
            if i[1] == 0:
                Ans[i[0]] = Ans[a]
            else:
                Ans[i[0]] = (Ans[a] + 1) % 2
            P.append(i[0]) i T[a] T a if Ans[i[0]] == -1:
            if i[1] == 0:
                Ans[i[0]] = Ans[a]
            else:
                Ans[i[0]] = (Ans[a] + 1) % 2
            P.append(i[0]) Ans[i[0]] == -1 Ans[i[0]] Ans i[0] i 0 -1 if i[1] == 0:
                Ans[i[0]] = Ans[a]
            else:
                Ans[i[0]] = (Ans[a] + 1) % 2
             i[1] == 0 i[1] i 1 0 Ans[i[0]] = Ans[a] Ans[i[0]] Ans i[0] i 0 Ans[a] Ans a Ans[i[0]] = (Ans[a] + 1) % 2 Ans[i[0]] Ans i[0] i 0 (Ans[a] + 1) % 2 Ans[a] + 1 Ans[a] Ans a 1 2 P.append(i[0]) P.append P append i[0] i 0 for i in Ans:
    print(i) i Ans print(i) print i Ans = [-1]*N [-1]*N Ans T = [[] for _ in range(N)] [[] for _ in range(N)] T v, w = u-1, v-1, w % 2 v-1 v P = deque([0]) deque([0]) P w = map(int, input().split()) map(int, input().split()) w a = P.popleft() P.popleft() a u, v, w = u-1, v-1, w % 2 u-1 u N = int(input()) int(input()) N v, w = map(int, input().split()) map(int, input().split()) v u, v, w = map(int, input().split()) map(int, input().split()) u w = u-1, v-1, w % 2 w % 2 w
from collections import deque
N = int(input())
T = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u, v, w = u-1, v-1, w % 2
    T[u].append([v, w])
    T[v].append([u, w])

Ans = [-1]*N
P = deque([0])
Ans[0] = 0
while(len(P) > 0):
    a = P.popleft()
    for i in T[a]:
        if Ans[i[0]] == -1:
            if i[1] == 0:
                Ans[i[0]] = Ans[a]
            else:
                Ans[i[0]] = (Ans[a] + 1) % 2
            P.append(i[0])
for i in Ans:
    print(i)