N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A,B,C = list(map(int,input().split()))
    G[A-1].append([C,B-1]) #重み、向かう先の順番
    G[B-1].append([C,A-1])

from collections import deque
dist = [None]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for c,w in G[v]:
        if dist[w] is not None:
            continue
        dist[w] = d + c
        que.append(w)
for i in range(N):
    print(dist[i]%2) 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) [] G = [[] for i in range(N)] G [[] for i in range(N)] for i in range(N-1):
    A,B,C = list(map(int,input().split()))
    G[A-1].append([C,B-1]) #重み、向かう先の順番
    G[B-1].append([C,A-1]) i range(N-1) range N-1 N 1 A,B,C = list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split B C G[A-1].append([C,B-1]) [A-1].append [A-1] G A-1 A 1 append [C,B-1] C B-1 B 1 G[B-1].append([C,A-1]) [B-1].append [B-1] G B-1 B 1 append [C,A-1] C A-1 A 1 from collections import deque dist = [None]*N dist [None]*N [None] None N que = deque([0]) que deque([0]) deque [0] 0 dist[0] = 0 dist[0] dist 0 0 while que:
    v = que.popleft()
    d = dist[v]
    for c,w in G[v]:
        if dist[w] is not None:
            continue
        dist[w] = d + c
        que.append(w) que v = que.popleft() v que.popleft() que.popleft que popleft d = dist[v] d dist[v] dist v for c,w in G[v]:
        if dist[w] is not None:
            continue
        dist[w] = d + c
        que.append(w) c w G[v] G v if dist[w] is not None:
            continue
         dist[w] is not None dist[w] dist w None continue dist[w] = d + c dist[w] dist w d + c d c que.append(w) que.append que append w for i in range(N):
    print(dist[i]%2) i range(N) range N print(dist[i]%2) print dist[i]%2 dist[i] dist i 2 G = [[] for i in range(N)] [[] for i in range(N)] G B,C = list(map(int,input().split())) list(map(int,input().split())) B dist = [None]*N [None]*N dist N = int(input()) int(input()) N A,B,C = list(map(int,input().split())) list(map(int,input().split())) A v = que.popleft() que.popleft() v que = deque([0]) deque([0]) que C = list(map(int,input().split())) list(map(int,input().split())) C d = dist[v] dist[v] d
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A,B,C = list(map(int,input().split()))
    G[A-1].append([C,B-1]) #重み、向かう先の順番
    G[B-1].append([C,A-1])

from collections import deque
dist = [None]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for c,w in G[v]:
        if dist[w] is not None:
            continue
        dist[w] = d + c
        que.append(w)
for i in range(N):
    print(dist[i]%2)