#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))


(setf n (read))
(setf m (read))

(defun distance (a b)
  (+ (abs (- (car a) (car b))) (abs (- (cdr a) (cdr b)))))

(defun nearest (p l)
  (setf res 0)
  (dotimes (i n)
	(when (> (distance p (aref l res)) (distance p (aref l i)))
	  (setf res i)))
  (1+ res))

(let ((a (loop for i from 1 to n collect (cons (read) (read))))
	  (b (concatenate 'vector (loop for i from 1 to m collect (cons (read) (read))))))
	  (mapc (lambda (target)
			  (princ (nearest target b))
			  (fresh-line))
			a))
