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