from collections import deque
n = int(input())
to = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u , v = u-1, v-1
    to[u].append([v, w])
    to[v].append([u, w])
color = [-1] * n
color[0] = 0
q = deque([0])
while q:
    v = q.popleft()
    for u, w in to[v]:
        if color[u] != -1:
            continue
        if w % 2 != 0:
            color[u] = color[v] ^ 1
        else:
            color[u] = color[v]
        q.append(u)
for c in color:
    print(c) 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) [] to = [[] for _ in range(n)] to [[] for _ in range(n)] for i in range(n-1):
    u, v, w = map(int, input().split())
    u , v = u-1, v-1
    to[u].append([v, w])
    to[v].append([u, 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 u , v = u-1, v-1 u u-1 u 1 v v-1 v 1 to[u].append([v, w]) [u].append [u] to u append [v, w] v w to[v].append([u, w]) [v].append [v] to v append [u, w] u w color = [-1] * n color [-1] * n [-1] -1 n color[0] = 0 color[0] color 0 0 q = deque([0]) q deque([0]) deque [0] 0 while q:
    v = q.popleft()
    for u, w in to[v]:
        if color[u] != -1:
            continue
        if w % 2 != 0:
            color[u] = color[v] ^ 1
        else:
            color[u] = color[v]
        q.append(u) q v = q.popleft() v q.popleft() q.popleft q popleft for u, w in to[v]:
        if color[u] != -1:
            continue
        if w % 2 != 0:
            color[u] = color[v] ^ 1
        else:
            color[u] = color[v]
        q.append(u) u w to[v] to v if color[u] != -1:
            continue
         color[u] != -1 color[u] color u -1 continue if w % 2 != 0:
            color[u] = color[v] ^ 1
        else:
            color[u] = color[v]
         w % 2 != 0 w % 2 w 2 0 color[u] = color[v] ^ 1 color[u] color u color[v] ^ 1 color[v] color v 1 color[u] = color[v] color[u] color u color[v] color v q.append(u) q.append q append u for c in color:
    print(c) c color print(c) print c to = [[] for _ in range(n)] [[] for _ in range(n)] to v, w = map(int, input().split()) map(int, input().split()) v v = q.popleft() q.popleft() v n = int(input()) int(input()) n w = map(int, input().split()) map(int, input().split()) w v = u-1, v-1 v-1 v q = deque([0]) deque([0]) q u , v = u-1, v-1 u-1 u color = [-1] * n [-1] * n color u, v, w = map(int, input().split()) map(int, input().split()) u
from collections import deque
n = int(input())
to = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u , v = u-1, v-1
    to[u].append([v, w])
    to[v].append([u, w])
color = [-1] * n
color[0] = 0
q = deque([0])
while q:
    v = q.popleft()
    for u, w in to[v]:
        if color[u] != -1:
            continue
        if w % 2 != 0:
            color[u] = color[v] ^ 1
        else:
            color[u] = color[v]
        q.append(u)
for c in color:
    print(c)