#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

struct Node {
	int sum;
	int min;
};

Node merge(const Node& a, const Node& b) {
	return {a.sum + b.sum, min(a.min, a.sum + b.min)};
}

struct Segtree {
	int n;
	vector<Node> a;

	Segtree(int _n) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		a.resize(n + n, {0, 0});
	}

	void add(int pos, int x) {
		pos += n;
		a[pos].sum += x;
		a[pos].min = min(a[pos].sum, 0);
		while (pos > 1) {
			pos /= 2;
			a[pos] = merge(a[pos + pos], a[pos + pos + 1]);
		}
	}
};

void solve() {
	int n = nxt();
	vector<pair<int, int>> a(2 * n);
	for (int i = 0; i < 2 * n; ++i) {
		a[i] = {nxt(), i};
	}
	sort(all(a));
	reverse(all(a));

	long long ans = 0;
	Segtree tree(n);
	for (int i = 0; i < n; ++i) {
		tree.add(i, 1);
	}
	for (auto [x, i_] : a) {
		int i = i_ < n ? n - 1 - i_ : i_ - n;
		tree.add(i, -1);
		if (tree.a[1].min < 0) {
			tree.add(i, 1);
		} else {
			ans += x;
		}
	}
	cout << ans << "\n";
}

int main() {
	int t = 1; // nxt();
	while (t--) {
		solve();
	}

	return 0;
}

#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

long long solve(long long H, long long W, int N, int M, const std::vector<long long> &A,
                const std::vector<long long> &B, const std::vector<long long> &C, const std::vector<long long> &D) {
  vector<vector<int>> grid(H, vector<int>(W, 0));
  vector<vector<bool>> light(H, vector<bool>(W, false));

  REP(i, N) { grid[A[i]][B[i]] = 1; }
  REP(i, M) { grid[C[i]][D[i]] = 2; }

  REP(i, H) {
    // 右方向
    int prev = 0;
    REP(j, W) {
      if (grid[i][j] == 2) {
        prev = 2;
        continue;
      }
      if (grid[i][j] == 1 || prev == 1) {
        prev = 1;
        light[i][j] = true;
      }
    }

    prev = 0;
    for (int j = W - 1; j >= 0; j--) {
      if (grid[i][j] == 2) {
        prev = 2;
        continue;
      }
      if (grid[i][j] == 1 || prev == 1) {
        prev = 1;
        light[i][j] = true;
      }
    }
  }

  REP(j, W) {
    int prev = 0;

    REP(i, H) {
      if (grid[i][j] == 2) {
        prev = 2;
        continue;
      }
      if (grid[i][j] == 1 || prev == 1) {
        prev = 1;
        light[i][j] = true;
      }
    }

    prev = 0;
    for (int i = H - 1; i >= 0; i--) {
      if (grid[i][j] == 2) {
        prev = 2;
        continue;
      }
      if (grid[i][j] == 1 || prev == 1) {
        prev = 1;
        light[i][j] = true;
      }
    }
  }

  int ans = 0;
  REP(i, H) {
    REP(j, W) {
      if (light[i][j]) {
        ans++;
      }
    }
  }
  return ans;
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main() {
  int H, W;
  int N, M;
  std::cin >> H >> W >> N;
  std::vector<long long> A(N), B(N);
  std::cin >> M;
  std::vector<long long> C(M), D(M);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  for (int i = 0; i < M; ++i) {
    std::cin >> C[i] >> D[i];
    C[i]--;
    D[i]--;
  }
  auto ans = solve(H, W, N, M, A, B, C, D);
  std::cout << ans << std::endl;
  return 0;
}
