from collections import deque

n = int(input())
edge = [list(map(int, input().split())) for _ in range(n-1)]

adj = [[] for _ in range(n+1)]

for i in range(n-1):
    u, v, w = edge[i]
    adj[u].append([v, w])
    adj[v].append([u, w])

q = deque([1])

dist = [0] * (n+1)
visited = [False] * (n+1)

while len(q) > 0:
    v = q.popleft()
    for w, d in adj[v]:
        if not visited[w]:
            visited[w] = True
            dist[w] = dist[v] + d
            q.append(w)

#print(dist)

for i in range(1, n+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1) from collections import deque n = int(input()) n int(input()) int input() input list(map(int, input().split())) for _ in range(n-1) for _ in range(n-1) _ range(n-1) range n-1 n 1 for _ in range(n-1) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split edge = [list(map(int, input().split())) for _ in range(n-1)] edge [list(map(int, input().split())) for _ in range(n-1)] [] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [] adj = [[] for _ in range(n+1)] adj [[] for _ in range(n+1)] for i in range(n-1):
    u, v, w = edge[i]
    adj[u].append([v, w])
    adj[v].append([u, w]) i range(n-1) range n-1 n 1 u, v, w = edge[i] u edge[i] edge i v w adj[u].append([v, w]) [u].append [u] adj u append [v, w] v w adj[v].append([u, w]) [v].append [v] adj v append [u, w] u w q = deque([1]) q deque([1]) deque [1] 1 dist = [0] * (n+1) dist [0] * (n+1) [0] 0 n+1 n 1 visited = [False] * (n+1) visited [False] * (n+1) [False] False n+1 n 1 while len(q) > 0:
    v = q.popleft()
    for w, d in adj[v]:
        if not visited[w]:
            visited[w] = True
            dist[w] = dist[v] + d
            q.append(w)

#print(dist) len(q) > 0 len(q) len q 0 v = q.popleft() v q.popleft() q.popleft q popleft for w, d in adj[v]:
        if not visited[w]:
            visited[w] = True
            dist[w] = dist[v] + d
            q.append(w)

#print(dist) w d adj[v] adj v if not visited[w]:
            visited[w] = True
            dist[w] = dist[v] + d
            q.append(w)

#print(dist) not visited[w] visited[w] visited w visited[w] = True visited[w] visited w True dist[w] = dist[v] + d dist[w] dist w dist[v] + d dist[v] dist v d q.append(w) q.append q append w for i in range(1, n+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1) i range(1, n+1) range 1 n+1 n 1 if dist[i] % 2 == 0:
        print(0)
    else:
        print(1) dist[i] % 2 == 0 dist[i] % 2 dist[i] dist i 2 0 print(0) print 0 print(1) print 1 n = int(input()) int(input()) n w = edge[i] edge[i] w visited = [False] * (n+1) [False] * (n+1) visited v, w = edge[i] edge[i] v edge = [list(map(int, input().split())) for _ in range(n-1)] [list(map(int, input().split())) for _ in range(n-1)] edge v = q.popleft() q.popleft() v u, v, w = edge[i] edge[i] u dist = [0] * (n+1) [0] * (n+1) dist q = deque([1]) deque([1]) q adj = [[] for _ in range(n+1)] [[] for _ in range(n+1)] adj
from collections import deque

n = int(input())
edge = [list(map(int, input().split())) for _ in range(n-1)]

adj = [[] for _ in range(n+1)]

for i in range(n-1):
    u, v, w = edge[i]
    adj[u].append([v, w])
    adj[v].append([u, w])

q = deque([1])

dist = [0] * (n+1)
visited = [False] * (n+1)

while len(q) > 0:
    v = q.popleft()
    for w, d in adj[v]:
        if not visited[w]:
            visited[w] = True
            dist[w] = dist[v] + d
            q.append(w)

#print(dist)

for i in range(1, n+1):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)