from collections import deque
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])
used = [0]*n
used[0] = 1
parity = [-1]*n
parity[0] = 0
que = deque()
que.append(0)
while que:
    # print(que)
    v = que.popleft()
    for nv, w in g[v]:
        if used[nv]:
            continue
        parity[nv] = (parity[v] + w)%2
        used[nv] = 1
        que.append(nv)

# print(used)
for i in range(n):
    print(parity[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) [] g = [[] for _ in range(n)] g [[] for _ in range(n)] for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[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 -= 1 u 1 v -= 1 v 1 g[u].append([v, w]) [u].append [u] g u append [v, w] v w g[v].append([u, w]) [v].append [v] g v append [u, w] u w used = [0]*n used [0]*n [0] 0 n used[0] = 1 used[0] used 0 1 parity = [-1]*n parity [-1]*n [-1] -1 n parity[0] = 0 parity[0] parity 0 0 que = deque() que deque() deque que.append(0) que.append que append 0 while que:
    # print(que)
    v = que.popleft()
    for nv, w in g[v]:
        if used[nv]:
            continue
        parity[nv] = (parity[v] + w)%2
        used[nv] = 1
        que.append(nv)

# print(used) que v = que.popleft() v que.popleft() que.popleft que popleft for nv, w in g[v]:
        if used[nv]:
            continue
        parity[nv] = (parity[v] + w)%2
        used[nv] = 1
        que.append(nv)

# print(used) nv w g[v] g v if used[nv]:
            continue
         used[nv] used nv continue parity[nv] = (parity[v] + w)%2 parity[nv] parity nv (parity[v] + w)%2 parity[v] + w parity[v] parity v w 2 used[nv] = 1 used[nv] used nv 1 que.append(nv) que.append que append nv for i in range(n):
    print(parity[i]) i range(n) range n print(parity[i]) print parity[i] parity i v, w = map(int, input().split()) map(int, input().split()) v que = deque() deque() que v -= 1 1 v parity = [-1]*n [-1]*n parity n = int(input()) int(input()) n u -= 1 1 u v = que.popleft() que.popleft() v w = map(int, input().split()) map(int, input().split()) w used = [0]*n [0]*n used u, v, w = map(int, input().split()) map(int, input().split()) u g = [[] for _ in range(n)] [[] for _ in range(n)] g
from collections import deque
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])
used = [0]*n
used[0] = 1
parity = [-1]*n
parity[0] = 0
que = deque()
que.append(0)
while que:
    # print(que)
    v = que.popleft()
    for nv, w in g[v]:
        if used[nv]:
            continue
        parity[nv] = (parity[v] + w)%2
        used[nv] = 1
        que.append(nv)

# print(used)
for i in range(n):
    print(parity[i])