from collections import deque
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n=int(input())

tree=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=nii()
  u-=1
  v-=1
  tree[u].append([v,w])
  tree[v].append([u,w])

ans=[-1 for i in range(n)]
ans[0]=0

que=deque()
que.append(0)

while que:
  x=que.popleft()
  for i in tree[x]:
    nx=i[0]
    nw=i[1]
    if ans[nx]==-1:
      que.append(nx)
      if nw%2==0:
        ans[nx]=ans[x]
      else:
        ans[nx]=(ans[x]+1)%2

for i in ans:
  print(i) from collections import deque from sys import stdin nii=lambda:map(int,stdin.readline().split()) nii lambda:map(int,stdin.readline().split()) map(int,stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split 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) [] tree=[[] for i in range(n)] tree [[] for i in range(n)] for i in range(n-1):
  u,v,w=nii()
  u-=1
  v-=1
  tree[u].append([v,w])
  tree[v].append([u,w]) i range(n-1) range n-1 n 1 u,v,w=nii() u nii() nii v w u-=1 u 1 v-=1 v 1 tree[u].append([v,w]) [u].append [u] tree u append [v,w] v w tree[v].append([u,w]) [v].append [v] tree v append [u,w] u w -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 ans=[-1 for i in range(n)] ans [-1 for i in range(n)] ans[0]=0 ans[0] ans 0 0 que=deque() que deque() deque que.append(0) que.append que append 0 while que:
  x=que.popleft()
  for i in tree[x]:
    nx=i[0]
    nw=i[1]
    if ans[nx]==-1:
      que.append(nx)
      if nw%2==0:
        ans[nx]=ans[x]
      else:
        ans[nx]=(ans[x]+1)%2 que x=que.popleft() x que.popleft() que.popleft que popleft for i in tree[x]:
    nx=i[0]
    nw=i[1]
    if ans[nx]==-1:
      que.append(nx)
      if nw%2==0:
        ans[nx]=ans[x]
      else:
        ans[nx]=(ans[x]+1)%2 i tree[x] tree x nx=i[0] nx i[0] i 0 nw=i[1] nw i[1] i 1 if ans[nx]==-1:
      que.append(nx)
      if nw%2==0:
        ans[nx]=ans[x]
      else:
        ans[nx]=(ans[x]+1)%2 ans[nx]==-1 ans[nx] ans nx -1 que.append(nx) que.append que append nx if nw%2==0:
        ans[nx]=ans[x]
      else:
        ans[nx]=(ans[x]+1)%2 nw%2==0 nw%2 nw 2 0 ans[nx]=ans[x] ans[nx] ans nx ans[x] ans x ans[nx]=(ans[x]+1)%2 ans[nx] ans nx (ans[x]+1)%2 ans[x]+1 ans[x] ans x 1 2 for i in ans:
  print(i) i ans print(i) print i ans=[-1 for i in range(n)] [-1 for i in range(n)] ans nii=lambda:map(int,stdin.readline().split()) lambda:map(int,stdin.readline().split()) nii que=deque() deque() que u-=1 1 u nw=i[1] i[1] nw tree=[[] for i in range(n)] [[] for i in range(n)] tree x=que.popleft() que.popleft() x v,w=nii() nii() v nx=i[0] i[0] nx n=int(input()) int(input()) n u,v,w=nii() nii() u w=nii() nii() w v-=1 1 v
from collections import deque
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n=int(input())

tree=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=nii()
  u-=1
  v-=1
  tree[u].append([v,w])
  tree[v].append([u,w])

ans=[-1 for i in range(n)]
ans[0]=0

que=deque()
que.append(0)

while que:
  x=que.popleft()
  for i in tree[x]:
    nx=i[0]
    nw=i[1]
    if ans[nx]==-1:
      que.append(nx)
      if nw%2==0:
        ans[nx]=ans[x]
      else:
        ans[nx]=(ans[x]+1)%2

for i in ans:
  print(i)