#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
int a,b,n,m;
int f[510][510];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
struct node{
int x,y,time;
bool used=0;
}now,net;
struct id{
int x,y;
}f1[510*510];
queue<node> q;
bool in(int x,int y){
return x>=0&&x<n&&y>=0&&y<m;
}
int cnt=0;
int bfs(){
now.x=f1[++cnt].x,now.y=f1[++cnt].y;
q.push(now);
f[now.x][now.y]=0;
while(!q.empty()){
now=q.front();
q.pop();
if(f[now.x][now.y]==2){
return now.time;
}
for(int i=0;i<4;i++){
net.x=now.x+dx[i];
net.y=now.y+dy[i];
net.time=now.time++;
if(in(net.x,net.y)&&!net.used){
q.push(net);
net.used=114514;
}
}
}
}
int main(){
cin>>n>>m>>a>>b;
for(int i=0;i<a;i++){
int x1,y1;
cin>>x1>>y1;
f[x1][y1]=1;
f1[i].x=x1;
f1[i].y=y1;
}
for(int i=0;i<b;i++){
int x1,y1;
cin>>x1>>y1;
f[x1][y1]=2;
f1[a+i-1].x=x1;
f1[a+i-1].y=y1;
}
cout<<bfs();
return 0;
}