n = int(input())

g = [[] for _ in range(n)]

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

from collections import deque

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

g = [[] for _ in range(n)]

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

from collections import deque

que = deque()
seen = [0] + [-1]*(n-1)
que.append(0)
while que:
    s = que.popleft()
    for v,w in g[s]:
        if seen[v] != -1:continue
        seen[v] = seen[s]^(w%2)
        que.append(v)
for i in seen:
    print(i)