N = int(input())
adj = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append((v, w))
    adj[v].append((u, w))

stack = [0]
color = [-1]*N
color[0] = 0
while stack:
    v = stack.pop()
    for child, w in adj[v]:
        if color[child] < 0:
            color[child] = (color[v] + w) % 2
            stack.append(child)

for i in color:
    print(i) 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) [] adj = [[] for _ in range(N)] adj [[] for _ in range(N)] for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append((v, w))
    adj[v].append((u, w)) _ 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 u -= 1 u 1 v -= 1 v 1 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 stack = [0] stack [0] 0 color = [-1]*N color [-1]*N [-1] -1 N color[0] = 0 color[0] color 0 0 while stack:
    v = stack.pop()
    for child, w in adj[v]:
        if color[child] < 0:
            color[child] = (color[v] + w) % 2
            stack.append(child) stack v = stack.pop() v stack.pop() stack.pop stack pop for child, w in adj[v]:
        if color[child] < 0:
            color[child] = (color[v] + w) % 2
            stack.append(child) child w adj[v] adj v if color[child] < 0:
            color[child] = (color[v] + w) % 2
            stack.append(child) color[child] < 0 color[child] color child 0 color[child] = (color[v] + w) % 2 color[child] color child (color[v] + w) % 2 color[v] + w color[v] color v w 2 stack.append(child) stack.append stack append child for i in color:
    print(i) i color print(i) print i u, v, w = map(int, input().split()) map(int, input().split()) u u -= 1 1 u stack = [0] [0] stack v -= 1 1 v v = stack.pop() stack.pop() v w = map(int, input().split()) map(int, input().split()) w adj = [[] for _ in range(N)] [[] for _ in range(N)] adj N = int(input()) int(input()) N v, w = map(int, input().split()) map(int, input().split()) v color = [-1]*N [-1]*N color
N = int(input())
adj = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append((v, w))
    adj[v].append((u, w))

stack = [0]
color = [-1]*N
color[0] = 0
while stack:
    v = stack.pop()
    for child, w in adj[v]:
        if color[child] < 0:
            color[child] = (color[v] + w) % 2
            stack.append(child)

for i in color:
    print(i)