program sample
    implicit none
  
    integer(8) :: i,j,m,n,x,y,s,t
    integer(8),allocatable :: a(:),b(:),c(:),d(:)
  
    read(*,*) n,m
    allocate(a(n),b(n),c(m),d(m))
    do i=1,n
    read(*,*)a(i),b(i)
    end do
    do i=1,m
    read(*,*)c(i),d(i)
    end do
    do i=1,n
        x=a(i)
        y=b(i)
        s=abs(x-c(1))+abs(y-d(1))
        t=1
        do j=2,m
            if(abs(x-c(j))+abs(y-d(j))<s)then
                s= abs(x-c(j))+abs(y-d(j))
                t=j
            end if
        end do
        write(*,*) t
    end do         

   
  
    stop
end program sample
  

