#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <math.h>
#include <random>
#include <chrono>
#include <assert.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
template<class T> using V = vector<T> ;
template<class T> using VV = V<V<T>> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1e9+7 ;
long double pie = acos(-1) ;
ll INF = 1e18 ;
 
void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll extGCD(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x = 1 ;
        y = 0 ;
        return a ;
    }
    ll d = extGCD(b,a%b,y,x) ;
    y -= a/b*x ;
    return d ;
}
void fix_cout(){cout << fixed << setprecision(20) ;}
template<class T> void chmax(T &a,T b){if(a<b) a = b ;}
template<class T> void chmin(T &a,T b){if(a>b) a = b ;}

string ans = "" ;
int mx = 0 ;
VV<int> a(50,V<int>(50)) ;
VV<int> t(50,V<int>(50)) ;
VV<bool> tt(50,V<bool>(50,true)) ;

chrono::_V2::system_clock::time_point start,now ;

void DFS(int y,int x,int sum,string &cur){
  now = chrono::system_clock::now() ;
  if(chrono::duration_cast<chrono::milliseconds>(now-start).count()>1000) return ;
  sum += a[y][x] ;
  if(mx<sum){
    mx = sum ;
    ans = cur ;
  }
  tt[y][x] = false ;
  if(y>0&&t[y-1][x]==t[y][x]) tt[y-1][x] = false ;
  if(y+1<50&&t[y+1][x]==t[y][x]) tt[y+1][x] = false ;
  if(x>0&&t[y][x-1]==t[y][x]) tt[y][x-1] = false ;
  if(x+1<50&&t[y][x+1]==t[y][x]) tt[y][x+1] = false ;
  cur += 'U' ;
  if(y>0&&tt[y-1][x]) DFS(y-1,x,sum,cur) ;
  cur.pop_back() ; cur += 'D' ;
  if(y+1<50&&tt[y+1][x]) DFS(y+1,x,sum,cur) ;
  cur.pop_back() ; cur += 'L' ;
  if(x>0&&tt[y][x-1]) DFS(y,x-1,sum,cur) ;
  cur.pop_back() ; cur += 'R' ;
  if(x+1<50&&tt[y][x+1]) DFS(y,x+1,sum,cur) ;
  cur.pop_back() ;
  tt[y][x] = true ;
  if(y>0&&t[y-1][x]==t[y][x]) tt[y-1][x] = true ;
  if(y+1<50&&t[y+1][x]==t[y][x]) tt[y+1][x] = true ;
  if(x>0&&t[y][x-1]==t[y][x]) tt[y][x-1] = true ;
  if(x+1<50&&t[y][x+1]==t[y][x]) tt[y][x+1] = true ;
}
void DFS2(int y,int x,int sum,string &cur){
  now = chrono::system_clock::now() ;
  if(chrono::duration_cast<chrono::milliseconds>(now-start).count()>1970) return ;
  sum += a[y][x] ;
  if(mx<sum){
    mx = sum ;
    ans = cur ;
  }
  tt[y][x] = false ;
  if(y>0&&t[y-1][x]==t[y][x]) tt[y-1][x] = false ;
  if(y+1<50&&t[y+1][x]==t[y][x]) tt[y+1][x] = false ;
  if(x>0&&t[y][x-1]==t[y][x]) tt[y][x-1] = false ;
  if(x+1<50&&t[y][x+1]==t[y][x]) tt[y][x+1] = false ;
  cur += 'R' ;
  if(x+1<50&&tt[y][x+1]) DFS2(y,x+1,sum,cur) ;
  cur.pop_back() ; cur += 'L' ;
  if(x>0&&tt[y][x-1]) DFS2(y,x-1,sum,cur) ;
  cur.pop_back() ; cur += 'D' ;
  if(y+1<50&&tt[y+1][x]) DFS2(y+1,x,sum,cur) ;
  cur.pop_back() ; cur += 'U' ;
  if(y>0&&tt[y-1][x]) DFS2(y-1,x,sum,cur) ;
  cur.pop_back() ;
  tt[y][x] = true ;
  if(y>0&&t[y-1][x]==t[y][x]) tt[y-1][x] = true ;
  if(y+1<50&&t[y+1][x]==t[y][x]) tt[y+1][x] = true ;
  if(x>0&&t[y][x-1]==t[y][x]) tt[y][x-1] = true ;
  if(x+1<50&&t[y][x+1]==t[y][x]) tt[y][x+1] = true ;
}

int main(){
  start = chrono::system_clock::now() ;
  int sx,sy ;
  cin >> sy >> sx ;
  for(auto &i:t) for(auto &j:i) cin >> j ;
  for(auto &i:a) for(auto &j:i) cin >> j ;
  int sum = 0 ;
  string cur = "" ;
  DFS(sy,sx,sum,cur) ;
  sum = 0 ;
  cur = "" ;
  for(int i=0;i<50;i++) for(int j=0;j<50;j++) tt[i][j] = true ;
  DFS2(sy,sx,sum,cur) ;
  cout << ans << endl ;
}
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
#define irep(i,n) for(int i = n-1; i >= 0; --i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int N=1505;
int v[N][N];
int main() {
  int h,w,n,m;
  cin >> h >> w >> n >> m;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    v[a-1][b-1] = 2;
  }
  rep(i,m){
    int a,b;
    cin >> a >> b;
    v[a-1][b-1] = -1;
  }
  bool b;
  rep(i,h){
    b=false;
    rep(j,w){
      if(v[i][j]==-1) b = false;
      if(v[i][j]==2) b = true;
      if(v[i][j]==0 && b) v[i][j] = 1;  
    }
    b=false;
    irep(j,w){
      if(v[i][j]==-1) b = false;
      if(v[i][j]==2) b = true;
      if(v[i][j]==0 && b) v[i][j] = 1;  
    }
  }
  rep(j,w){
    b=false;
    rep(i,h){
      if(v[i][j]==-1) b = false;
      if(v[i][j]==2) b = true;
      if(v[i][j]==0 && b) v[i][j] = 1;  
    }
    b=false;
    irep(i,h){
      if(v[i][j]==-1) b = false;
      if(v[i][j]==2) b = true;
      if(v[i][j]==0 && b) v[i][j] = 1;  
    }
  }

  int ans = 0;
  rep(i,h)rep(j,w) if(v[i][j]>0) ++ans;
  cout << ans << endl;
}
