import javafx.util.Pair;

import java.util.*;

public class Security {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int guardsCount = sc.nextInt();
        int incidentCount = sc.nextInt();
        Pair<Integer,Integer>[] guards = new Pair[guardsCount];
        Map<Pair<Integer,Integer>,Boolean> mappings = new HashMap<>();
        for (int i = 0;i<guardsCount;i++) {
            mappings.put(new Pair<>(sc.nextInt(),sc.nextInt()),true);
        }
        Pair<Integer,Integer>[] incidents = new Pair[incidentCount];
        for (int i = 0;i<incidentCount;i++) {

            int incidentX = sc.nextInt();
            int incidentY = sc.nextInt();

            if (mappings.get(new Pair<>(incidentX,incidentY)) != null) {
                System.out.println(0);
                continue;
            }
            Queue<Pair<Pair<Integer,Integer>,Integer>> fronta = new ArrayDeque<>();
            boolean found = false;
            Map<Pair<Integer,Integer>,Boolean> visited = new HashMap<>();
            fronta.add(new Pair<>(new Pair<>(incidentX,incidentY),0));
            while (!found) {
                Pair<Pair<Integer,Integer>,Integer> current = fronta.remove();
                if (mappings.get(new Pair<>(current.getKey().getKey(),current.getKey().getValue())) != null) {
                    System.out.println(current.getValue());
                    found = true;
                    continue;
                }
                Pair<Pair<Integer,Integer>,Integer> adding;
                Pair<Integer,Integer> nextPos;
                for (int j = -1;j<=1;j++) {
                    for (int l = -1;l<=1;l++) {
                        nextPos = new Pair(current.getKey().getKey()+j,current.getKey().getValue()+l);
                        if (visited.get(nextPos) != null || nextPos.getValue() < 0 || nextPos.getValue() > 5000 || nextPos.getKey() < 0 || nextPos.getKey() > 5000 ) {
                            continue;
                        }
                        adding = new Pair<>(nextPos,current.getValue()+1);
                        fronta.add(adding);
                    }
                }
            }
        }
    }
}
