from collections import deque

N = int(input())

length = {}
conn = [[] for _ in range(N + 1)]
for i in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    conn[u].append(v)
    conn[v].append(u)
    length[(u, v)] = w

q = deque([1])
dist = [-1] * (N + 1)
dist[1] = 0
while q:
    u = q.popleft()
    for v in conn[u]:
        if dist[v] == -1:
            if u < v:
                dist[v] = dist[u] + length[(u, v)]
            else:
                dist[v] = dist[u] + length[(v, u)]
            q.append(v)

for i in range(1, N + 1):
    print(dist[i] % 2) from collections import deque N = int(input()) N int(input()) int input() input length = {} length {} [] for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) [] conn = [[] for _ in range(N + 1)] conn [[] for _ in range(N + 1)] for i in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    conn[u].append(v)
    conn[v].append(u)
    length[(u, v)] = w i range(N - 1) range N - 1 N 1 int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x u, v, w = [int(x) for x in input().split()] u [int(x) for x in input().split()] v w conn[u].append(v) [u].append [u] conn u append v conn[v].append(u) [v].append [v] conn v append u length[(u, v)] = w length[(u, v)] length (u, v) u v w q = deque([1]) q deque([1]) deque [1] 1 dist = [-1] * (N + 1) dist [-1] * (N + 1) [-1] -1 N + 1 N 1 dist[1] = 0 dist[1] dist 1 0 while q:
    u = q.popleft()
    for v in conn[u]:
        if dist[v] == -1:
            if u < v:
                dist[v] = dist[u] + length[(u, v)]
            else:
                dist[v] = dist[u] + length[(v, u)]
            q.append(v) q u = q.popleft() u q.popleft() q.popleft q popleft for v in conn[u]:
        if dist[v] == -1:
            if u < v:
                dist[v] = dist[u] + length[(u, v)]
            else:
                dist[v] = dist[u] + length[(v, u)]
            q.append(v) v conn[u] conn u if dist[v] == -1:
            if u < v:
                dist[v] = dist[u] + length[(u, v)]
            else:
                dist[v] = dist[u] + length[(v, u)]
            q.append(v) dist[v] == -1 dist[v] dist v -1 if u < v:
                dist[v] = dist[u] + length[(u, v)]
            else:
                dist[v] = dist[u] + length[(v, u)]
             u < v u v dist[v] = dist[u] + length[(u, v)] dist[v] dist v dist[u] + length[(u, v)] dist[u] dist u length[(u, v)] length (u, v) u v dist[v] = dist[u] + length[(v, u)] dist[v] dist v dist[u] + length[(v, u)] dist[u] dist u length[(v, u)] length (v, u) v u q.append(v) q.append q append v for i in range(1, N + 1):
    print(dist[i] % 2) i range(1, N + 1) range 1 N + 1 N 1 print(dist[i] % 2) print dist[i] % 2 dist[i] dist i 2 N = int(input()) int(input()) N u = q.popleft() q.popleft() u u, v, w = [int(x) for x in input().split()] [int(x) for x in input().split()] u dist = [-1] * (N + 1) [-1] * (N + 1) dist length = {} {} length q = deque([1]) deque([1]) q w = [int(x) for x in input().split()] [int(x) for x in input().split()] w conn = [[] for _ in range(N + 1)] [[] for _ in range(N + 1)] conn v, w = [int(x) for x in input().split()] [int(x) for x in input().split()] v
from collections import deque

N = int(input())

length = {}
conn = [[] for _ in range(N + 1)]
for i in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    conn[u].append(v)
    conn[v].append(u)
    length[(u, v)] = w

q = deque([1])
dist = [-1] * (N + 1)
dist[1] = 0
while q:
    u = q.popleft()
    for v in conn[u]:
        if dist[v] == -1:
            if u < v:
                dist[v] = dist[u] + length[(u, v)]
            else:
                dist[v] = dist[u] + length[(v, u)]
            q.append(v)

for i in range(1, N + 1):
    print(dist[i] % 2)