import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
tree=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=mp()
    tree[a].append([a,b,c])
    tree[b].append([b,a,c])
ans=[-1]*(n+1)
ans[1]=0
que=deque()
que.append(tree[1])
while len(que):
    q=que.popleft()
    for x,y,z in q:
        if ans[y]==-1:
            ans[y]=(ans[x]+z)%2
            que.append(tree[y])
print(*ans[1:],sep="\n") import sys sys from collections import Counter from collections import deque import heapq heapq import math math import fractions fractions import bisect bisect import itertools itertools def input(): return sys.stdin.readline().strip() input def mp(): return map(int,input().split()) mp def lmp(): return list(map(int,input().split())) lmp n=int(input()) n int(input()) int input() input [] for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) [] tree=[[] for i in range(n+1)] tree [[] for i in range(n+1)] for i in range(n-1):
    a,b,c=mp()
    tree[a].append([a,b,c])
    tree[b].append([b,a,c]) i range(n-1) range n-1 n 1 a,b,c=mp() a mp() mp b c tree[a].append([a,b,c]) [a].append [a] tree a append [a,b,c] a b c tree[b].append([b,a,c]) [b].append [b] tree b append [b,a,c] b a c ans=[-1]*(n+1) ans [-1]*(n+1) [-1] -1 n+1 n 1 ans[1]=0 ans[1] ans 1 0 que=deque() que deque() deque que.append(tree[1]) que.append que append tree[1] tree 1 while len(que):
    q=que.popleft()
    for x,y,z in q:
        if ans[y]==-1:
            ans[y]=(ans[x]+z)%2
            que.append(tree[y]) len(que) len que q=que.popleft() q que.popleft() que.popleft que popleft for x,y,z in q:
        if ans[y]==-1:
            ans[y]=(ans[x]+z)%2
            que.append(tree[y]) x y z q if ans[y]==-1:
            ans[y]=(ans[x]+z)%2
            que.append(tree[y]) ans[y]==-1 ans[y] ans y -1 ans[y]=(ans[x]+z)%2 ans[y] ans y (ans[x]+z)%2 ans[x]+z ans[x] ans x z 2 que.append(tree[y]) que.append que append tree[y] tree y print(*ans[1:],sep="\n") print *ans[1:] ans[1:] ans 1: 1 sep="\n" sep "\n" c=mp() mp() c b,c=mp() mp() b n=int(input()) int(input()) n q=que.popleft() que.popleft() q ans=[-1]*(n+1) [-1]*(n+1) ans def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input que=deque() deque() que a,b,c=mp() mp() a def mp(): return map(int,input().split()) def mp(): return map(int,input().split()) mp def lmp(): return list(map(int,input().split())) def lmp(): return list(map(int,input().split())) lmp tree=[[] for i in range(n+1)] [[] for i in range(n+1)] tree
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
tree=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=mp()
    tree[a].append([a,b,c])
    tree[b].append([b,a,c])
ans=[-1]*(n+1)
ans[1]=0
que=deque()
que.append(tree[1])
while len(que):
    q=que.popleft()
    for x,y,z in q:
        if ans[y]==-1:
            ans[y]=(ans[x]+z)%2
            que.append(tree[y])
print(*ans[1:],sep="\n")