// Problem: P1332 血色先锋队
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1332
// Memory Limit: 125 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 510;
int dist[N][N];
queue<PII> q;
int n, m, a, b;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
void bfs() {
while (!q.empty()) {
auto t = q.front();
q.pop();
for (int i = 0; i < 4; i ++ ) {
int a = t.x + dx[i], b = t.y + dy[i];
if (a < 1 || a > n || b < 0 || b > m) continue;
if (dist[a][b] >= 0) continue;
dist[a][b] = dist[t.x][t.y] + 1;
q.push({a, b});
}
}
}
int main() {
cin >> n >> m >> a >> b;
memset(dist, -1, sizeof dist);
while (a -- ) {
int x, y;
cin >> x >> y;
q.push({x, y});
dist[x][y] = 0;
}
// bfs跑一遍整个地图
bfs();
while (b -- ) {
int x, y;
cin >> x >> y;
cout << dist[x][y] << '\n';
}
return 0;
}