from collections import deque

n = int(input())
L = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    L[u-1].append((v-1, w))
    L[v-1].append((u-1, w))
d = [-1] * n
d[0] = 0
c = [0] * n
c[0] = 0
q = deque([0])
while q:
    t = q.popleft()
    dist = d[t]
    for v, w in L[t]:
        if d[v] < 0:
            d[v] = dist + w
            if d[v] % 2:
                c[v] = 1
            q.append(v)
for x in c:
    print(x) 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) [] L = [[] for _ in range(n)] L [[] for _ in range(n)] for _ in range(n-1):
    u, v, w = map(int, input().split())
    L[u-1].append((v-1, w))
    L[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 L[u-1].append((v-1, w)) [u-1].append [u-1] L u-1 u 1 append (v-1, w) v-1 v 1 w L[v-1].append((u-1, w)) [v-1].append [v-1] L v-1 v 1 append (u-1, w) u-1 u 1 w d = [-1] * n d [-1] * n [-1] -1 n d[0] = 0 d[0] d 0 0 c = [0] * n c [0] * n [0] 0 n c[0] = 0 c[0] c 0 0 q = deque([0]) q deque([0]) deque [0] 0 while q:
    t = q.popleft()
    dist = d[t]
    for v, w in L[t]:
        if d[v] < 0:
            d[v] = dist + w
            if d[v] % 2:
                c[v] = 1
            q.append(v) q t = q.popleft() t q.popleft() q.popleft q popleft dist = d[t] dist d[t] d t for v, w in L[t]:
        if d[v] < 0:
            d[v] = dist + w
            if d[v] % 2:
                c[v] = 1
            q.append(v) v w L[t] L t if d[v] < 0:
            d[v] = dist + w
            if d[v] % 2:
                c[v] = 1
            q.append(v) d[v] < 0 d[v] d v 0 d[v] = dist + w d[v] d v dist + w dist w if d[v] % 2:
                c[v] = 1
             d[v] % 2 d[v] d v 2 c[v] = 1 c[v] c v 1 q.append(v) q.append q append v for x in c:
    print(x) x c print(x) print x d = [-1] * n [-1] * n d v, w = map(int, input().split()) map(int, input().split()) v n = int(input()) int(input()) n t = q.popleft() q.popleft() t w = map(int, input().split()) map(int, input().split()) w q = deque([0]) deque([0]) q L = [[] for _ in range(n)] [[] for _ in range(n)] L c = [0] * n [0] * n c u, v, w = map(int, input().split()) map(int, input().split()) u dist = d[t] d[t] dist
from collections import deque

n = int(input())
L = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    L[u-1].append((v-1, w))
    L[v-1].append((u-1, w))
d = [-1] * n
d[0] = 0
c = [0] * n
c[0] = 0
q = deque([0])
while q:
    t = q.popleft()
    dist = d[t]
    for v, w in L[t]:
        if d[v] < 0:
            d[v] = dist + w
            if d[v] % 2:
                c[v] = 1
            q.append(v)
for x in c:
    print(x)
