program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,i,j,dst,ans
    integer(int32), 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
        dst=1000000000
        do j=1,m
            if (abs(a(i)-c(j))+abs(b(i)-d(j))  < dst) then
                ans=j
                dst = abs(a(i)-c(j))+abs(b(i)-d(j))
            end if
        end do
        print*, ans
    end do
end program name