#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <complex>
#define ll long long
#define inf 1e9 + 6
#define sinf 1e15 + 500
#define ld long double
#define ull unsigned long long
#define poll complex<double>
#define line pair<poll, poll>
#define pi acos(-1)
#define lp(a, b, c, d) for (ll a = b; a < c; a += d)
#define endl '\n'
#define EPS 1e-12
#define IO                          \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);                   \
  // freopen("sum.in", "r", stdin);
#define mod 998244353
using namespace std;
const ll N = 2e5 + 5, SEG = (1 << 14);
int n;
vector<pair<int,int>>v;
vector<pair<int,int>>loc;
ll dp[N][2];
ll solve(int las,bool w)
{
  if(las==loc.size()-1)
  {
    if(w)return abs(v[loc[las].second].first);
    else return abs(v[loc[las].first].first);
  }

  ll &ret=dp[las][w];
  if(ret!=-1)return ret;

    ll x;
    if(w)x=v[loc[las].second].first;
    else x=v[loc[las].first].first;
  return ret=min(solve(las+1,0)+abs(v[loc[las+1].second].first-x)+abs(v[loc[las+1].second].first-v[loc[las+1].first].first)        ,
              solve(las+1,1)+abs(v[loc[las+1].first].first-x)+abs(v[loc[las+1].second].first-v[loc[las+1].first].first)
                    );
}
int main()
{
  IO
  cin>>n;
  int a,b;
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<n;i++)
  {
    cin>>a>>b;
    v.push_back({a,b});

  }
    sort(v.begin(),v.end(),[](pair<int,int>a,pair<int,int>c){
      if(a.second==c.second)return a.first<c.first;
      else return a.second<c.second;
    });
    v.insert(v.begin(),{0,0});
    loc.push_back({0,0});
    for(int i=1;i<v.size();i++)
    {
      if(v[i].second!=v[i-1].second)
      {
        loc.push_back({i,i});
      }
      else loc.back().second=i;
    }
    cout<<solve(0,0)<<endl;



    


  
  return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))

const int INF = 1e18;
const int mod = 1e9+7;


ostream &operator<<( ostream &output, const pii &p ) { output << p.first << " " << p.second;return output; }
istream &operator>>( istream &input, pii &p ) { input >> p.first >> p.second;return input; }
template<typename T>
void inline println(vector<T> args){ for(T i: args)cout<<i<<" ";cout<<endl; }


int power(int a, int b) {
    if (b == 0)
        return 1;
    int res = power(a, b / 2);
    if (b % 2)
        return (res * res * a);
    else
        return (res * res);
}



void solve() {
	int h, w, n, m; cin>>h>>w>>n>>m;
    set<int> row[h+1], col[w+1];
    rep(i, 1, h+1) {
        row[i].insert(0);
        row[i].insert(w+1);
    }
    rep(i, 1, w+1) {
        col[i].insert(0);
        col[i].insert(h+1);
    }
    vii bulbs(n);
    rep(i, 0, n) cin>>bulbs[i];
    rep(i, 0, m) {
        int x, y; cin>>x>>y;
        row[x].insert(y);
        col[y].insert(x);
    }
    int preRow[h+2][w+2] = {};
    int preCol[h+2][w+2] = {};
    int mat[h+2][w+2] = {};
    for(auto bulb: bulbs) {
        int x = bulb.first;
        int y = bulb.second;
        auto temp = col[y].upper_bound(x);
        int greaterRow = *temp;
        int lesserRow = *prev(temp);
        temp = row[x].upper_bound(y);
        int greaterCol = *temp;
        // for(int i: col[x]) cout<<i<<" ";
        // cout<<endl;
        int lesserCol = *prev(temp);
        preCol[lesserRow+1][y] ++;
        preCol[greaterRow][y] --;
        preRow[x][lesserCol+1] ++;
        preRow[x][greaterCol] --;
    }
    rep(j, 0, w+1) {
        rep(i, 0, h+1) {
            if(i-1 >= 0)
                preCol[i][j] += preCol[i-1][j];
            mat[i][j] += preCol[i][j];
        }
    }
    rep(i, 0, h+1) {
        rep(j, 0, w+1) {
            if(j-1 >= 0)
                preRow[i][j] += preRow[i][j-1];
            mat[i][j] += preRow[i][j];
        }
    }
    int ans = 0;
    rep(i, 0, h+2) {
        rep(j, 0, w+2)
            if(mat[i][j]) ans++;
    }
    cout<<ans<<endl;
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
