program kadai
implicit none

integer  ::  in
integer,allocatable  ::  u(:),v(:),w(:),flag(:),a(:)
integer  ::  i,j
read(*,*) in

allocate(u(in))
allocate(v(in))
allocate(w(in))
allocate(flag(in))
allocate(a(in))

do i=1,in-1
read(*,*) u(i),v(i),w(i)
a(i)=0
end do
a(in)=0

do j=1,in-1
if(u(i)==j) then
if(mod(w(i),2)==0) then
a(u(i))=1
a(v(i))=1
end if
end if
end do

do i=1,in
write(*,*) a(i)
end do




end program kadai