#include<bits/stdc++.h>
using namespace std;
namespace HQ{
#define int long long
void init(){
iossync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}struct node{
int x,y,step=0;
}l,r;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int n,m,a,b;
int mp[1145][1145];
int sx,sy,ex,ey;
bool vis[1145][1145];
int local[114514][15];
int times[1145][1145];
void Main(){
init();
cin>>n>>m>>a>>b;
queue<node>q;
for(int i=1;i<=a;i++){
int x,y;
cin>>x>>y;
q.push({x,y});
vis[x][y]=1;
}for(int i=1;i<=b;i++){
cin>>local[i][1]>>local[i][2];
}while(q.size()){
r=q.front();
q.pop();
for(int i=0;i<4;i++){
l.x=r.x+dx[i];
l.y=r.y+dy[i];
if(l.x>=1 and l.x<=n and l.y>=1 and l.y<=m and !vis[l.x][l.y]){
l.step=r.step+1;
q.push(l);
vis[l.x][l.y]=1;
}
}times[r.x][r.y]=r.step;
}for(int i=1;i<=b;i++){
cout<<times[local[i][1]][local[i][2]]<<'\n';
}
return;
}
}signed main(){
HQMain();
return (LLONG_MAX+LLONG_MIN+1LL)*114514LL/signed(2147483648);
}