#include<iostream>
#include<algorithm>
#include<cstring>
#define x first
#define y second
using namespace std;
typedef pair<int,int>PII;
const int N=600;
PII q[N*N];
int dist[N][N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int hh,tt;
int n,m,a,b;//a 感染源,b 领主
void bfs()
{
while(hh<=tt)
{
auto t=q[hh++];
for(int i=0;i<4;i++)
{
int a=t.x+dx[i],b=t.y+dy[i];
if(a<1 || a>n || b<1 || b>m)continue;
if(dist[a][b]>=0)continue;
dist[a][b]=dist[t.x][t.y]+1;
q[++tt]={a,b};
}
}
}
int main()
{
scanf("%d %d %d %d",&n,&m,&a,&b);
memset(dist,-1,sizeof(dist));
while(a--)
{
int x,y;
scanf("%d %d",&x,&y);
q[++tt]={x,y};
dist[x][y]=0;
}
bfs();
while(b--)
{
int x,y;
scanf("%d %d",&x,&y);
printf("%d\n",dist[x][y]);
}
return 0;
}