n = int(input())
uvw = [0]*(n-1)
for i in range(n-1):
    uvw[i] = list(map(int,input().split()))
V = [[] for i in range(n+1)]
for u,v,w in uvw:
    V[u].append([v,w])
    V[v].append([u,w])
from collections import deque
q = deque([])
now = 1
reach = [0]*(n+1)
reach[now] = 2
q.append(now)
while q:
    x = q.popleft()
    for L in V[x]:
        if reach[L[0]] == 0:
            q.append(L[0])
            reach[L[0]] = reach[x] + L[1]
for A in reach[1:]:
    if A%2 == 0:
        print(0)
    else:
        print(1) n = int(input()) n int(input()) int input() input uvw = [0]*(n-1) uvw [0]*(n-1) [0] 0 n-1 n 1 for i in range(n-1):
    uvw[i] = list(map(int,input().split())) i range(n-1) range n-1 n 1 uvw[i] = list(map(int,input().split())) uvw[i] uvw i list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split [] 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) [] V = [[] for i in range(n+1)] V [[] for i in range(n+1)] for u,v,w in uvw:
    V[u].append([v,w])
    V[v].append([u,w]) u v w uvw V[u].append([v,w]) [u].append [u] V u append [v,w] v w V[v].append([u,w]) [v].append [v] V v append [u,w] u w from collections import deque q = deque([]) q deque([]) deque [] now = 1 now 1 reach = [0]*(n+1) reach [0]*(n+1) [0] 0 n+1 n 1 reach[now] = 2 reach[now] reach now 2 q.append(now) q.append q append now while q:
    x = q.popleft()
    for L in V[x]:
        if reach[L[0]] == 0:
            q.append(L[0])
            reach[L[0]] = reach[x] + L[1] q x = q.popleft() x q.popleft() q.popleft q popleft for L in V[x]:
        if reach[L[0]] == 0:
            q.append(L[0])
            reach[L[0]] = reach[x] + L[1] L V[x] V x if reach[L[0]] == 0:
            q.append(L[0])
            reach[L[0]] = reach[x] + L[1] reach[L[0]] == 0 reach[L[0]] reach L[0] L 0 0 q.append(L[0]) q.append q append L[0] L 0 reach[L[0]] = reach[x] + L[1] reach[L[0]] reach L[0] L 0 reach[x] + L[1] reach[x] reach x L[1] L 1 for A in reach[1:]:
    if A%2 == 0:
        print(0)
    else:
        print(1) A reach[1:] reach 1: 1 if A%2 == 0:
        print(0)
    else:
        print(1) A%2 == 0 A%2 A 2 0 print(0) print 0 print(1) print 1 V = [[] for i in range(n+1)] [[] for i in range(n+1)] V reach = [0]*(n+1) [0]*(n+1) reach uvw = [0]*(n-1) [0]*(n-1) uvw n = int(input()) int(input()) n x = q.popleft() q.popleft() x now = 1 1 now q = deque([]) deque([]) q
n = int(input())
uvw = [0]*(n-1)
for i in range(n-1):
    uvw[i] = list(map(int,input().split()))
V = [[] for i in range(n+1)]
for u,v,w in uvw:
    V[u].append([v,w])
    V[v].append([u,w])
from collections import deque
q = deque([])
now = 1
reach = [0]*(n+1)
reach[now] = 2
q.append(now)
while q:
    x = q.popleft()
    for L in V[x]:
        if reach[L[0]] == 0:
            q.append(L[0])
            reach[L[0]] = reach[x] + L[1]
for A in reach[1:]:
    if A%2 == 0:
        print(0)
    else:
        print(1)