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

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

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