from collections import deque

N = int(input())
ki = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    ki[u-1].append([v-1, w])
    ki[v-1].append([u-1, w])
f = [False]*N
f[0] = True
c = [0]*N

q = deque([0])
while q:
    now = q.popleft()
    for nxt, w in ki[now]:
        if f[nxt]:
            continue
        if w&1:
            c[nxt] = c[now]^1
        else:
            c[nxt] = c[now]
        q.append(nxt)
        f[nxt] = True


for a in c:
    print(a) 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) [] ki = [[] for _ in range(N)] ki [[] for _ in range(N)] for _ in range(N-1):
    u, v, w = map(int, input().split())
    ki[u-1].append([v-1, w])
    ki[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 ki[u-1].append([v-1, w]) [u-1].append [u-1] ki u-1 u 1 append [v-1, w] v-1 v 1 w ki[v-1].append([u-1, w]) [v-1].append [v-1] ki v-1 v 1 append [u-1, w] u-1 u 1 w f = [False]*N f [False]*N [False] False N f[0] = True f[0] f 0 True c = [0]*N c [0]*N [0] 0 N q = deque([0]) q deque([0]) deque [0] 0 while q:
    now = q.popleft()
    for nxt, w in ki[now]:
        if f[nxt]:
            continue
        if w&1:
            c[nxt] = c[now]^1
        else:
            c[nxt] = c[now]
        q.append(nxt)
        f[nxt] = True q now = q.popleft() now q.popleft() q.popleft q popleft for nxt, w in ki[now]:
        if f[nxt]:
            continue
        if w&1:
            c[nxt] = c[now]^1
        else:
            c[nxt] = c[now]
        q.append(nxt)
        f[nxt] = True nxt w ki[now] ki now if f[nxt]:
            continue
         f[nxt] f nxt continue if w&1:
            c[nxt] = c[now]^1
        else:
            c[nxt] = c[now]
         w&1 w 1 c[nxt] = c[now]^1 c[nxt] c nxt c[now]^1 c[now] c now 1 c[nxt] = c[now] c[nxt] c nxt c[now] c now q.append(nxt) q.append q append nxt f[nxt] = True f[nxt] f nxt True for a in c:
    print(a) a c print(a) print a ki = [[] for _ in range(N)] [[] for _ in range(N)] ki v, w = map(int, input().split()) map(int, input().split()) v q = deque([0]) deque([0]) q u, v, w = map(int, input().split()) map(int, input().split()) u c = [0]*N [0]*N c now = q.popleft() q.popleft() now f = [False]*N [False]*N f w = map(int, input().split()) map(int, input().split()) w N = int(input()) int(input()) N
from collections import deque

N = int(input())
ki = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    ki[u-1].append([v-1, w])
    ki[v-1].append([u-1, w])
f = [False]*N
f[0] = True
c = [0]*N

q = deque([0])
while q:
    now = q.popleft()
    for nxt, w in ki[now]:
        if f[nxt]:
            continue
        if w&1:
            c[nxt] = c[now]^1
        else:
            c[nxt] = c[now]
        q.append(nxt)
        f[nxt] = True


for a in c:
    print(a)