#include using namespace std; using ll=long long; constexpr int MOD=998244353; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,l,r) for(int i=(l);i<(int)(r);i++) #define all(v) v.begin(),v.end() constexpr int MAX_X=1000; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector dist(MAX_X,vector(MAX_X,(int)1e9)); queue>bfs; rep(i,N){ int X,Y; cin>>X>>Y; dist[X][Y]=0; bfs.push({X,Y}); } int dx[]={0,1,0,-1}; int dy[]={-1,0,1,0}; auto bound_ok=[&](int x,int y){ return x>=0&&x=0&&ydist[x][y]+1){ dist[x2][y2]=dist[x][y]+1; bfs.push({x2,y2}); } } } int ans=1e9; int M; cin>>M; rep(i,M){ int X,Y; cin>>X>>Y; ans=min(ans,dist[X][Y]); } cout<