import sys
input = sys.stdin.readline
from collections import deque
N = int(input())
lis = [[] for i in range(N)]
for i in range(N-1):
    a,b,w = map(int,input().split())
    lis[a-1].append((b-1,w%2))#移動先、偶奇の順
    lis[b-1].append((a-1,w%2))

flg = [True] * N
ans = [-1] * N
que = deque([ (0,0) ])
#flg[0] = False
ans[0] = 0
flg[0] = False
while len(que) != 0:
    p = que.popleft()
    #print(p)
    for i in lis[p[0]]:
        if flg[i[0]] == True:
            que.append(i)
            flg[i[0]] = False
            if i[1] == 0:
                ans[i[0]] = ans[p[0]]
            else:
                if ans[p[0]] == 1:
                    ans[i[0]] = 0
                else:
                    ans[i[0]] = 1
for i in ans:
    print(i) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import deque N = int(input()) N int(input()) int input() input [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] lis = [[] for i in range(N)] lis [[] for i in range(N)] for i in range(N-1):
    a,b,w = map(int,input().split())
    lis[a-1].append((b-1,w%2))#移動先、偶奇の順
    lis[b-1].append((a-1,w%2)) i range(N-1) range N-1 N 1 a,b,w = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b w lis[a-1].append((b-1,w%2)) [a-1].append [a-1] lis a-1 a 1 append (b-1,w%2) b-1 b 1 w%2 w 2 lis[b-1].append((a-1,w%2)) [b-1].append [b-1] lis b-1 b 1 append (a-1,w%2) a-1 a 1 w%2 w 2 flg = [True] * N flg [True] * N [True] True N ans = [-1] * N ans [-1] * N [-1] -1 N que = deque([ (0,0) ]) que deque([ (0,0) ]) deque [ (0,0) ] (0,0) 0 0 ans[0] = 0 ans[0] ans 0 0 flg[0] = False flg[0] flg 0 False while len(que) != 0:
    p = que.popleft()
    #print(p)
    for i in lis[p[0]]:
        if flg[i[0]] == True:
            que.append(i)
            flg[i[0]] = False
            if i[1] == 0:
                ans[i[0]] = ans[p[0]]
            else:
                if ans[p[0]] == 1:
                    ans[i[0]] = 0
                else:
                    ans[i[0]] = 1 len(que) != 0 len(que) len que 0 p = que.popleft() p que.popleft() que.popleft que popleft for i in lis[p[0]]:
        if flg[i[0]] == True:
            que.append(i)
            flg[i[0]] = False
            if i[1] == 0:
                ans[i[0]] = ans[p[0]]
            else:
                if ans[p[0]] == 1:
                    ans[i[0]] = 0
                else:
                    ans[i[0]] = 1 i lis[p[0]] lis p[0] p 0 if flg[i[0]] == True:
            que.append(i)
            flg[i[0]] = False
            if i[1] == 0:
                ans[i[0]] = ans[p[0]]
            else:
                if ans[p[0]] == 1:
                    ans[i[0]] = 0
                else:
                    ans[i[0]] = 1 flg[i[0]] == True flg[i[0]] flg i[0] i 0 True que.append(i) que.append que append i flg[i[0]] = False flg[i[0]] flg i[0] i 0 False if i[1] == 0:
                ans[i[0]] = ans[p[0]]
            else:
                if ans[p[0]] == 1:
                    ans[i[0]] = 0
                else:
                    ans[i[0]] = 1 i[1] == 0 i[1] i 1 0 ans[i[0]] = ans[p[0]] ans[i[0]] ans i[0] i 0 ans[p[0]] ans p[0] p 0 if ans[p[0]] == 1:
                    ans[i[0]] = 0
                else:
                    ans[i[0]] = 1 ans[p[0]] == 1 ans[p[0]] ans p[0] p 0 1 ans[i[0]] = 0 ans[i[0]] ans i[0] i 0 0 ans[i[0]] = 1 ans[i[0]] ans i[0] i 0 1 for i in ans:
    print(i) i ans print(i) print i que = deque([ (0,0) ]) deque([ (0,0) ]) que p = que.popleft() que.popleft() p ans = [-1] * N [-1] * N ans input = sys.stdin.readline sys.stdin.readline input flg = [True] * N [True] * N flg N = int(input()) int(input()) N w = map(int,input().split()) map(int,input().split()) w lis = [[] for i in range(N)] [[] for i in range(N)] lis a,b,w = map(int,input().split()) map(int,input().split()) a b,w = map(int,input().split()) map(int,input().split()) b
import sys
input = sys.stdin.readline
from collections import deque
N = int(input())
lis = [[] for i in range(N)]
for i in range(N-1):
    a,b,w = map(int,input().split())
    lis[a-1].append((b-1,w%2))#移動先、偶奇の順
    lis[b-1].append((a-1,w%2))

flg = [True] * N
ans = [-1] * N
que = deque([ (0,0) ])
#flg[0] = False
ans[0] = 0
flg[0] = False
while len(que) != 0:
    p = que.popleft()
    #print(p)
    for i in lis[p[0]]:
        if flg[i[0]] == True:
            que.append(i)
            flg[i[0]] = False
            if i[1] == 0:
                ans[i[0]] = ans[p[0]]
            else:
                if ans[p[0]] == 1:
                    ans[i[0]] = 0
                else:
                    ans[i[0]] = 1
for i in ans:
    print(i)
