n = int(input())
explored = set()
next = [[]for _ in range(n)]

from collections import deque
ls = []
for i in range(n-1):
    u, v, w= map(int, input().split())
    ls.append((u-1, v-1, w%2))
    next[u-1].append((v-1, w%2))
    next[v-1].append((u-1, w%2))

ans = [-1] * n

exploring = deque()
next_que = deque([0])
ans[0]=0
explored.add(0)
while next_que:
    i = next_que.popleft()
    exploring.extend(next[i])
    while exploring:
        a, b = exploring.popleft()
        ans[a] = (ans[i]+b)%2
        list = next[a]
        if a not in explored:
            next_que.append(a)
        explored.add(a)


print(*ans, end='\n') n = int(input()) n int(input()) int input() input explored = set() explored set() set []for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] next = [[]for _ in range(n)] next [[]for _ in range(n)] from collections import deque ls = [] ls [] for i in range(n-1):
    u, v, w= map(int, input().split())
    ls.append((u-1, v-1, w%2))
    next[u-1].append((v-1, w%2))
    next[v-1].append((u-1, w%2)) i 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 ls.append((u-1, v-1, w%2)) ls.append ls append (u-1, v-1, w%2) u-1 u 1 v-1 v 1 w%2 w 2 next[u-1].append((v-1, w%2)) [u-1].append [u-1] next u-1 u 1 append (v-1, w%2) v-1 v 1 w%2 w 2 next[v-1].append((u-1, w%2)) [v-1].append [v-1] next v-1 v 1 append (u-1, w%2) u-1 u 1 w%2 w 2 ans = [-1] * n ans [-1] * n [-1] -1 n exploring = deque() exploring deque() deque next_que = deque([0]) next_que deque([0]) deque [0] 0 ans[0]=0 ans[0] ans 0 0 explored.add(0) explored.add explored add 0 while next_que:
    i = next_que.popleft()
    exploring.extend(next[i])
    while exploring:
        a, b = exploring.popleft()
        ans[a] = (ans[i]+b)%2
        list = next[a]
        if a not in explored:
            next_que.append(a)
        explored.add(a) next_que i = next_que.popleft() i next_que.popleft() next_que.popleft next_que popleft exploring.extend(next[i]) exploring.extend exploring extend next[i] next i while exploring:
        a, b = exploring.popleft()
        ans[a] = (ans[i]+b)%2
        list = next[a]
        if a not in explored:
            next_que.append(a)
        explored.add(a) exploring a, b = exploring.popleft() a exploring.popleft() exploring.popleft exploring popleft b ans[a] = (ans[i]+b)%2 ans[a] ans a (ans[i]+b)%2 ans[i]+b ans[i] ans i b 2 list = next[a] list next[a] next a if a not in explored:
            next_que.append(a)
         a not in explored a explored next_que.append(a) next_que.append next_que append a explored.add(a) explored.add explored add a print(*ans, end='\n') print *ans ans end='\n' end '\n' next_que = deque([0]) deque([0]) next_que i = next_que.popleft() next_que.popleft() i list = next[a] next[a] list explored = set() set() explored w= map(int, input().split()) map(int, input().split()) w n = int(input()) int(input()) n ls = [] [] ls exploring = deque() deque() exploring next = [[]for _ in range(n)] [[]for _ in range(n)] next ans = [-1] * n [-1] * n ans v, w= map(int, input().split()) map(int, input().split()) v a, b = exploring.popleft() exploring.popleft() a b = exploring.popleft() exploring.popleft() b u, v, w= map(int, input().split()) map(int, input().split()) u
n = int(input())
explored = set()
next = [[]for _ in range(n)]

from collections import deque
ls = []
for i in range(n-1):
    u, v, w= map(int, input().split())
    ls.append((u-1, v-1, w%2))
    next[u-1].append((v-1, w%2))
    next[v-1].append((u-1, w%2))

ans = [-1] * n

exploring = deque()
next_que = deque([0])
ans[0]=0
explored.add(0)
while next_que:
    i = next_que.popleft()
    exploring.extend(next[i])
    while exploring:
        a, b = exploring.popleft()
        ans[a] = (ans[i]+b)%2
        list = next[a]
        if a not in explored:
            next_que.append(a)
        explored.add(a)


print(*ans, end='\n')