#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S1, S2, S3;
#define NOANS "UNSOLVABLE"
//---------------------------------------------------------------------------------------------------
vector<char> chars;
char used[10];
bool check() {
	map<char, char> mapping;
	rep(i, 0, 10) if (used[i] != 0) mapping[used[i]] = char('0' + i);

	string SS1, SS2, SS3;
	fore(c, S1) SS1 += mapping[c];
	fore(c, S2) SS2 += mapping[c];
	fore(c, S3) SS3 += mapping[c];

	if (to_string(stoll(SS1)) != SS1) return false;
	if (to_string(stoll(SS2)) != SS2) return false;
	if (to_string(stoll(SS3)) != SS3) return false;
	if (stoll(SS1) + stoll(SS2) != stoll(SS3)) return false;
	if (stoll(SS1) == 0) return false;
	if (stoll(SS2) == 0) return false;
	if (stoll(SS3) == 0) return false;

	cout << SS1 << endl;
	cout << SS2 << endl;
	cout << SS3 << endl;
	return true;
}
bool dfs(int cu) {
	if (cu == chars.size()) return check();

	rep(i, 0, 10) if (used[i] == 0) {
		used[i] = chars[cu];
		if (dfs(cu + 1)) return true;
		used[i] = 0;
	}

	return false;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S1 >> S2 >> S3;

	fore(c, S1) chars.push_back(c);
	fore(c, S2) chars.push_back(c);
	fore(c, S3) chars.push_back(c);
	sort(all(chars));
	chars.erase(unique(all(chars)), chars.end());

	if (10 < chars.size()) {
		cout << NOANS << endl;
		return;
	}

	bool res = dfs(0);
	if (res == false) cout << NOANS << endl;
}






#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main() {
    int h, w, n, m;
    cin >> h >> w >> n >> m;
    vv<ll> vec(h + 1, vector<ll>(w + 1));
    vector<pi> lights;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        lights.emplace_back(a, b);
    }
    vv<bool> block(h, vector<bool>(w));
    rep(i, m) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        block[c][d] = true;
    }
    vv<int> right(h, vector<int>(w, w));
    vv<int> left(h, vector<int>(w, -1));
    vv<int> up(h, vector<int>(w, -1));
    vv<int> down(h, vector<int>(w, h));
    rep(i,h){
        int now = -1;
        rep(j,w){
            if(block[i][j]){
                now = j;
            } else {
                left[i][j] = now;
            }
        }
        now = w;
        rrep(j,w){
            if(block[i][j]){
                now = j;
            } else {
                right[i][j] = now;
            }
        }        
    }
    rep(j,w){
        int now = -1;
        rep(i,h){
            if(block[i][j]){
                now = i;
            } else {
                up[i][j] = now;
            }
        }
        now = h;
        rrep(i,h){
            if(block[i][j]){
                now = i;
            } else {
                down[i][j] = now;
            }
        }        
    }
    rep(i,n){
        int a, b;
        tie(a, b) = lights[i];
        int u = up[a][b];
        int d = down[a][b];
        int l = left[a][b];
        int r = right[a][b];
        vec[u+1][b]++;
        vec[u+1][b+1]--;
        vec[d][b]--;
        vec[d][b+1]++;
        vec[a][l+1]++;
        vec[a+1][l+1]--;
        vec[a][r]--;
        vec[a+1][r]++;
    }
    rep(i,h)rep(j,w){
        vec[i][j+1] += vec[i][j];
    }
    rep(j,w)rep(i,h){
        vec[i+1][j] += vec[i][j];
    }
    int ans = 0;
    rep(i,h)rep(j,w){
        if(vec[i][j]>0){
            ans++;
        }
    }
    cout << ans << '\n';
    
    
}
