program main
  implicit none
  integer :: n, m, i, j
  integer, allocatable :: ab(:, :), cd(:, :)
  read (*, *) n, m
  allocate (ab(2, n), cd(2, m))
  do i = 1, n
    read (*, *) ab(:, i)
  end do
  do i = 1, m
    read (*, *) cd(:, i)
  end do

  do i = 1, n
    write (*, "(i0)") closest_index(ab(:, i))
  end do
  contains

  integer function closest_index(student)
    integer, intent(in) :: student(2)
    integer :: mdmin, i, md
    mdmin = 99999999
    do i = 1, m
      md = abs(student(1) - cd(1, i)) + abs(student(2) - cd(2, i))
      if (md < mdmin) then
        closest_index = i
        mdmin = md
      end if
    end do
  end function closest_index
end program main
