from collections import deque
from collections import defaultdict

def to_str(l):
    return ''.join([str(x) for x in l])

def get_moves(x,y):
    l = [[x+1,y], [x+1,y+1], [x,y+1], [x+1,y-1], [x,y-1], [x-1,y-1], [x-1,y], [x-1,y+1]]
    # print(l)
    l = list(filter(lambda x: ((-1< x[0] <max_x) and (-1< x[1] <max_y)), l))
    # l = [[x[1],x[0]] for x in l]
    # print(l)
    return l

def BFS(start):
####    visited = [[False]*max_x for x in range(max_y)]
####    cnt_matrix = [[0]*max_x for x in range(max_y)]
    visited = defaultdict(lambda : False)
    cnt_matrix = defaultdict(lambda : 0)
    # visited = dict()
    # cnt_matrix = dict()
    # visited.set_default(False)
    # cnt_matrix.set_default(0)
    bfs_queue = deque()
    bfs_queue.append(start)
    cnt = 0
    # tmp = '>'
    while len(bfs_queue) != 0:
        x = bfs_queue.popleft()
        x_str = to_str(x)
        xi,xj = x[0],x[1]
        neigh = get_moves (xi,xj)
        # cnt += 1
        # print('from {}'.format(x))
        for w in neigh:
            # print(tmp*cnt,end='')
            # print(w)
            w_str = to_str(w)
            wj,wi = w[0],w[1]
####            if not visited[wi][wj]:
            if not visited[w_str]:
                bfs_queue.append(w)
                visited[w_str] = True
                cnt_matrix[w_str] = 1 + cnt_matrix[x_str]
####                cnt_matrix[wi][wj] = 1 + cnt_matrix[xj][xi]
####                visited[wi][wj] = True
####            # if matrix[wi][wj] == 1:
                if w_str in guard_coord_str:
                    return cnt_matrix[w_str]
                # for x in cnt_matrix[::-1]:
                #     print(x)


guard_cnt, incident_cnt = map(int, input().split())
# print(guard_cnt)
# print(incident_cnt)

guard_coord = [list(map(int, input().split())) for x in range(guard_cnt)]
incident_coord = [list(map(int, input().split())) for x in range(incident_cnt)]
# guard_coord_str = set(list(map(to_str, guard_coord)))
# incident_coord_str = set(list(map(to_str, incident_coord)))

guard_coord_str = list(map(to_str, guard_coord))
incident_coord_str = list(map(to_str, incident_coord))


# print(guard_coord_str)
# print(incident_coord_str)
#
# print(guard_coord_str)
# print(incident_coord_str)

common = []
common.extend(guard_coord)
common.extend(incident_coord)
common_x = [x[0] for x in common]
common_y = [y[1] for y in common]
max_x = max(common_x) + 1
max_y = max(common_y) + 1

# print(max_x)
# print(max_y)

#### matrix = [[0]*max_x for x in range(max_y)]
# print(matrix)

#### for x in guard_coord:
####     i,j = x[0],x[1]
####     matrix[j][i] = 1

#### for x in incident_coord:
####     i,j = x[0],x[1]
####     # print(i,j)
####     matrix[j][i] = 2

# matrix = matrix[::-1]
# for x in matrix[::-1]:
#     print(x)

# print(BFS(incident_coord[1]))
#### flag = True
# print(list(zip(incident_coord_str, incident_coord_str)))
for x,x_str in zip(incident_coord, incident_coord_str):
    # for w in guard_coord:
    #     if w == x:
    #         flag = False
    #         print(0)
    #         break
    if x_str in guard_coord_str:
        print(0)
    else:
        print(BFS(x))
    # flag = True
