from collections import deque
n = int(input())
trees = [[] for _ in range(n)]

for i in range(n-1):
    a, b, w = map(int, input().split())
    trees[a-1].append([b-1, w])
    trees[b-1].append([a-1, w])

color = [0 for _ in range(n)]
visited = set()

next = deque()
next.append(0)
visited.add(0)
color[0] = 1

while len(next):
    i = next.popleft()
    for j, d in trees[i]:
        if j in visited:
           continue
        if d % 2 == 0:
            color[j] = color[i]
        else:
            color[j] = color[i] * -1
        next.append(j)
        visited.add(j)

for i in color:
    if i == -1:
        print(0)
    else:
        print(i) from collections import deque 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) [] trees = [[] for _ in range(n)] trees [[] for _ in range(n)] for i in range(n-1):
    a, b, w = map(int, input().split())
    trees[a-1].append([b-1, w])
    trees[b-1].append([a-1, w]) i range(n-1) range n-1 n 1 a, b, w = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b w trees[a-1].append([b-1, w]) [a-1].append [a-1] trees a-1 a 1 append [b-1, w] b-1 b 1 w trees[b-1].append([a-1, w]) [b-1].append [b-1] trees b-1 b 1 append [a-1, w] a-1 a 1 w 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 color = [0 for _ in range(n)] color [0 for _ in range(n)] visited = set() visited set() set next = deque() next deque() deque next.append(0) next.append next append 0 visited.add(0) visited.add visited add 0 color[0] = 1 color[0] color 0 1 while len(next):
    i = next.popleft()
    for j, d in trees[i]:
        if j in visited:
           continue
        if d % 2 == 0:
            color[j] = color[i]
        else:
            color[j] = color[i] * -1
        next.append(j)
        visited.add(j) len(next) len next i = next.popleft() i next.popleft() next.popleft next popleft for j, d in trees[i]:
        if j in visited:
           continue
        if d % 2 == 0:
            color[j] = color[i]
        else:
            color[j] = color[i] * -1
        next.append(j)
        visited.add(j) j d trees[i] trees i if j in visited:
           continue
         j in visited j visited continue if d % 2 == 0:
            color[j] = color[i]
        else:
            color[j] = color[i] * -1
         d % 2 == 0 d % 2 d 2 0 color[j] = color[i] color[j] color j color[i] color i color[j] = color[i] * -1 color[j] color j color[i] * -1 color[i] color i -1 next.append(j) next.append next append j visited.add(j) visited.add visited add j for i in color:
    if i == -1:
        print(0)
    else:
        print(i) i color if i == -1:
        print(0)
    else:
        print(i) i == -1 i -1 print(0) print 0 print(i) print i a, b, w = map(int, input().split()) map(int, input().split()) a w = map(int, input().split()) map(int, input().split()) w next = deque() deque() next b, w = map(int, input().split()) map(int, input().split()) b visited = set() set() visited n = int(input()) int(input()) n i = next.popleft() next.popleft() i trees = [[] for _ in range(n)] [[] for _ in range(n)] trees color = [0 for _ in range(n)] [0 for _ in range(n)] color
from collections import deque
n = int(input())
trees = [[] for _ in range(n)]

for i in range(n-1):
    a, b, w = map(int, input().split())
    trees[a-1].append([b-1, w])
    trees[b-1].append([a-1, w])

color = [0 for _ in range(n)]
visited = set()

next = deque()
next.append(0)
visited.add(0)
color[0] = 1

while len(next):
    i = next.popleft()
    for j, d in trees[i]:
        if j in visited:
           continue
        if d % 2 == 0:
            color[j] = color[i]
        else:
            color[j] = color[i] * -1
        next.append(j)
        visited.add(j)

for i in color:
    if i == -1:
        print(0)
    else:
        print(i)