N = int(input())
data = [[] for _ in range(N)]
for _ in range(N-1):
    p, q, w = map(int, input().split())
    p -= 1
    q -= 1
    data[p].append((q,w))
    data[q].append((p,w))

colors = [0]*N
visited = [0]*N
start = 0
next_set = [start]
while next_set:
    p = next_set.pop()
    visited[p] = 1
    color = colors[p]
    for q, w in data[p]:
        if visited[q]:
            continue
        colors[q] = (color + w%2)%2
        next_set.append(q)
print(*colors, sep="\n") N = int(input()) N int(input()) int input() input [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] data = [[] for _ in range(N)] data [[] for _ in range(N)] for _ in range(N-1):
    p, q, w = map(int, input().split())
    p -= 1
    q -= 1
    data[p].append((q,w))
    data[q].append((p,w)) _ range(N-1) range N-1 N 1 p, q, w = map(int, input().split()) p map(int, input().split()) map int input().split() ().split () input split q w p -= 1 p 1 q -= 1 q 1 data[p].append((q,w)) [p].append [p] data p append (q,w) q w data[q].append((p,w)) [q].append [q] data q append (p,w) p w colors = [0]*N colors [0]*N [0] 0 N visited = [0]*N visited [0]*N [0] 0 N start = 0 start 0 next_set = [start] next_set [start] start while next_set:
    p = next_set.pop()
    visited[p] = 1
    color = colors[p]
    for q, w in data[p]:
        if visited[q]:
            continue
        colors[q] = (color + w%2)%2
        next_set.append(q) next_set p = next_set.pop() p next_set.pop() next_set.pop next_set pop visited[p] = 1 visited[p] visited p 1 color = colors[p] color colors[p] colors p for q, w in data[p]:
        if visited[q]:
            continue
        colors[q] = (color + w%2)%2
        next_set.append(q) q w data[p] data p if visited[q]:
            continue
         visited[q] visited q continue colors[q] = (color + w%2)%2 colors[q] colors q (color + w%2)%2 color + w%2 color w%2 w 2 2 next_set.append(q) next_set.append next_set append q print(*colors, sep="\n") print *colors colors sep="\n" sep "\n" data = [[] for _ in range(N)] [[] for _ in range(N)] data p, q, w = map(int, input().split()) map(int, input().split()) p visited = [0]*N [0]*N visited p = next_set.pop() next_set.pop() p color = colors[p] colors[p] color q, w = map(int, input().split()) map(int, input().split()) q N = int(input()) int(input()) N q -= 1 1 q next_set = [start] [start] next_set colors = [0]*N [0]*N colors w = map(int, input().split()) map(int, input().split()) w start = 0 0 start p -= 1 1 p
N = int(input())
data = [[] for _ in range(N)]
for _ in range(N-1):
    p, q, w = map(int, input().split())
    p -= 1
    q -= 1
    data[p].append((q,w))
    data[q].append((p,w))

colors = [0]*N
visited = [0]*N
start = 0
next_set = [start]
while next_set:
    p = next_set.pop()
    visited[p] = 1
    color = colors[p]
    for q, w in data[p]:
        if visited[q]:
            continue
        colors[q] = (color + w%2)%2
        next_set.append(q)
print(*colors, sep="\n")
