program main
   implicit none
   integer(8)::a,b,q,ma,mb,pa,pb
   integer(8)::i
   integer(8),allocatable,dimension(:)::s,t,x,dums,dumt
   read(*,*)a,b,q
   allocate(s(a),dums(a),t(b),dumt(b),x(q))
   do i=1,a
      read(*,*)s(i)
   enddo
   do i=1,b
      read(*,*)t(i)
   enddo 
   do i=1,q
      read(*,*)x(i)
   enddo
   do i=1,q
      dums=s-x(i)
      dumt=t-x(i)
      ma=minval(abs(dums),dums<=0)
      mb=minval(abs(dumt),dumt<=0)
      pa=minval(abs(dums),dums>=0)
      pb=minval(abs(dumt),dumt>=0)
      write(*,*)min(max(ma,mb),max(pa,pb),2*min(ma,pa)+min(mb,pb),min(ma,pa)+2*min(mb,pb))
   enddo
end program main
