#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int,int>;

int main() {
  int h,w,n,m;
  cin >> h >> w >> n >> m;
  vector<int> a(n), b(n);
  vector<vector<int>> done(h, vector<int>(w,0));
  rep(i,n){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }

  rep(i,m){
    int c, d;
    cin >> c >> d;
    c--; d--;
    done[c][d]--;
  }

  rep(i,n){
    if(!done[a[i]][b[i]]){
      int x = a[i];
      while(x >= 0 && done[x][b[i]] != -1) { done[x][b[i]] = 1; x--; }
      x = a[i];
      while(x < h && done[x][b[i]] != -1) { done[x][b[i]] = 1; x++; }
    }
  }

  rep(i,n){
    if(done[a[i]][b[i]] != 2){
      int y = b[i];
      while(y >= 0 && done[a[i]][y] != -1) { done[a[i]][y] = 2; y--; }
      y = b[i];
      while(y < w && done[a[i]][y] != -1) { done[a[i]][y] = 2; y++; }
    }
  }

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

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;

int N, M, TIME=clock();
vector<pair<int, string>> V;
vi C(8);
int sum = 0;
vector<string> S(20);

int total() {
	string s;
	int p = 0;
	set<string> t, u;
	rep(i, M) t.insert(V[i].second);
	vector<string> v(20);
	rep(i, N) v[i] = S[i];
	rep(q, 2) {
		rep(i, N) {
			s = v[i] + v[i];
			for (auto a : t) {
				bool f = false;
				rep(j, N) {
					if (a == s.substr(j, a.size())) {
						f = true;
						break;
					}
				}
				if (f) p += a.size();
				else u.insert(a);
			}
			t.clear();
			swap(t, u);
		}
		rep(i, N) { v[i].clear(); rep(j, N) v[i] += S[j][i]; }
	}
	return p;
}

int delta(int a, int b, int x, int y) {
	string s;
	int p = 0;
	set<string> t, u;
	rep(i, M) t.insert(V[i].second);
	rep(q, 2) {
		s = S[a] + S[a];
		for (auto r : t) {
			bool f = false;
			int c = (b+N-r.size()+1)%N;
			rep(j, r.size()) {
				if (r == s.substr(c+j, r.size())) {
					f = true;
					break;
				}
			}
			if (f) p += r.size();
			else u.insert(r);
		}
		t.clear();
		swap(t, u);
		swap(a, x);
	}
	rep(q, 2) {
		s = "";
		rep(i, N) s += S[i][b];
		rep(i, N) s += S[i][b];
		for (auto r : t) {
			bool f = false;
			int c = (a+N-r.size()+1)%N;
			rep(j, r.size()) {
				if (r == s.substr(c+j, r.size())) {
					f = true;
					break;
				}
			}
			if (f) p += r.size();
			else u.insert(r);
		}
		t.clear();
		swap(t, u);
		swap(b, y);
	}
	return p;
}

int delta_1(int a, int b) {
	string s;
	int p = 0;
	set<string> t, u;
	rep(i, M) t.insert(V[i].second);
	s = S[a] + S[a];
	for (auto r : t) {
		bool f = false;
		int c = (b+N-r.size()+1)%N;
		rep(j, r.size()) {
			if (r == s.substr(c+j, r.size())) {
				f = true;
				break;
			}
		}
		if (f) p += r.size();
		else u.insert(r);
	}
	t.clear();
	swap(t, u);

	s = "";
	rep(i, N) s += S[i][b];
	rep(i, N) s += S[i][b];
	for (auto r : t) {
		bool f = false;
		int c = (a+N-r.size()+1)%N;
		rep(j, r.size()) {
			if (r == s.substr(c+j, r.size())) {
				f = true;
				break;
			}
		}
		if (f) p += r.size();
		else u.insert(r);
	}
	t.clear();
	swap(t, u);
	return p;
}

int main() {
	cin >> N >> M;
	string s;
	rep(i, M) {
		cin >> s;
		V.pb({s.size(), s});
		rep(j, s.size()) C[s[j]-'A']++;
	}
	rep(i, 8) sum += C[i];
	rep(i, 7) C[i+1] += C[i];
	sort(all(V));

	int a=0, b=0, c=0, x, y, z;
	rep(i, N) {
		rep(j, N) {
			x = rand()%sum;
			rep(k, 8) {
				if (x < C[k]) {
					S[i] += 'A'+k;
					break;
				}
			}
		}
	}
	// show(total())
	int count = 0;
	while (true) {
		count++;
		a = rand()%N;
		b = rand()%N;
		if (count%5 == 0) {
			y = S[a][b]-'A';
			x = y;
			while (x == y) x = rand()%8;
			c = delta_1(a, b);
			S[a][b] = 'A'+x;
			z = delta_1(a, b);
			if (c > z) S[a][b] = 'A'+y;
		} else {
			x = rand()%N;
			y = rand()%N;
			c = delta(a, b, x, y);
			swap(S[a][b], S[x][y]);
			z = delta(a, b, x, y);
			if (c > z) swap(S[a][b], S[x][y]);
		}
		// list(c)list(z) show(total())
		if (clock()-TIME > 2.95 * CLOCKS_PER_SEC) break;
	}
	// show(count)
	rep(i, N) std::cout << S[i] << '\n';
}
