let rec search x y m cd index ans = 
if cd = [] 
then 
    ans
else
    let (c,d) = (List.hd cd)  in
    let dis = abs(x-c) + abs(y-d) in
    if dis <= m 
    then
        search x y dis (List.tl cd) (index-1) index
    else
        search x y m (List.tl cd) (index-1) ans;;


let n,m = Scanf.scanf "%d %d " (fun a b -> a,b) in 
let rec loop i= 
    if i <= 0 
    then
         [] 
    else
        (Scanf.scanf "%d %d " (fun a b -> a,b)) :: loop (i-1) in
let ab = List.rev (loop n) in 
let cd = loop m in
let rec loop2 ls = 
    match ls with
        |[] -> () 
        |(a,b)::tail ->  Printf.printf "%d\n" (search a b 1000000000 cd m 0);loop2 tail in
loop2 ab;;
