from collections import deque
n = int(input())
ans = [-1] * n
ans[0] = 0
d = [[] for _ in range(n)]

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

cnt = 0
queue = deque()
queue.append(0)
while queue:
    u = queue.pop()
    for v, w in d[u]:
        if ans[v] == -1:
            if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = ans[u] ^ 1
            queue.append(v)


for i in range(n):
    print(ans[i]) from collections import deque n = int(input()) n int(input()) int input() input ans = [-1] * n ans [-1] * n [-1] -1 n ans[0] = 0 ans[0] ans 0 0 [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] d = [[] for _ in range(n)] d [[] for _ in range(n)] for i in range(n - 1):
    u, v, w = map(int, input().split())
    d[u - 1].append([v - 1, w])
    d[v - 1].append([u - 1, w]) 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 d[u - 1].append([v - 1, w]) [u - 1].append [u - 1] d u - 1 u 1 append [v - 1, w] v - 1 v 1 w d[v - 1].append([u - 1, w]) [v - 1].append [v - 1] d v - 1 v 1 append [u - 1, w] u - 1 u 1 w cnt = 0 cnt 0 queue = deque() queue deque() deque queue.append(0) queue.append queue append 0 while queue:
    u = queue.pop()
    for v, w in d[u]:
        if ans[v] == -1:
            if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = ans[u] ^ 1
            queue.append(v) queue u = queue.pop() u queue.pop() queue.pop queue pop for v, w in d[u]:
        if ans[v] == -1:
            if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = ans[u] ^ 1
            queue.append(v) v w d[u] d u if ans[v] == -1:
            if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = ans[u] ^ 1
            queue.append(v) ans[v] == -1 ans[v] ans v -1 if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = ans[u] ^ 1
             w % 2 == 0 w % 2 w 2 0 ans[v] = ans[u] ans[v] ans v ans[u] ans u ans[v] = ans[u] ^ 1 ans[v] ans v ans[u] ^ 1 ans[u] ans u 1 queue.append(v) queue.append queue append v for i in range(n):
    print(ans[i]) i range(n) range n print(ans[i]) print ans[i] ans i w = map(int, input().split()) map(int, input().split()) w d = [[] for _ in range(n)] [[] for _ in range(n)] d v, w = map(int, input().split()) map(int, input().split()) v cnt = 0 0 cnt ans = [-1] * n [-1] * n ans u, v, w = map(int, input().split()) map(int, input().split()) u queue = deque() deque() queue n = int(input()) int(input()) n u = queue.pop() queue.pop() u
from collections import deque
n = int(input())
ans = [-1] * n
ans[0] = 0
d = [[] for _ in range(n)]

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

cnt = 0
queue = deque()
queue.append(0)
while queue:
    u = queue.pop()
    for v, w in d[u]:
        if ans[v] == -1:
            if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = ans[u] ^ 1
            queue.append(v)


for i in range(n):
    print(ans[i])