#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
    ll h,w,n,m;
    cin >> h >> w >> n >> m;
    VVl aka(h,Vl(w)),lit(h,Vl(w));
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        aka[x][y]+=2;
    }
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        aka[x][y]--;
    }
    rep(i,h)rep(j,w){
        
        if(aka[i][j]>0){
            while(j>0){
                if(aka[i][j-1]==-1)break;
                j--;

            }
            while(j<w){
            if(aka[i][j]==-1){
                //j++;
                break;
            }
            lit[i][j]++;
            j++;
            }
            
        }
        //cout << j << endl;
    }
    rep(j,w)rep(i,h){
        if(aka[i][j]>0){
            while(i>0){
                if(aka[i-1][j]==-1)break;
                i--;

            }
            while(i<h){
                if(aka[i][j]==-1){
                    //i++;
                    break;
                }
                lit[i][j]++;
                i++;
            
            }
            //cout << i << endl;
        }
    }
    ll ans=0;
    rep(i,h)rep(j,w){
        if(lit[i][j]>=1&&aka[i][j]>=0) ans++;
        //cout << lit[i][j] << endl;
    }
    cout << ans << endl;
}
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<long long>      vll;
typedef vector<pair<int, int>> vpi;

#define pb            push_back
#define pf            push_front
#define all(x)        begin(x), end(x)
#define sz(x)         (int)(x).size()
#define ff            first
#define ss            second
#define mp            make_pair
#define lb            lower_bound
#define ub            upper_bound
#define Tcase()       int tcc; cin >> tcc; while(tcc--)
#define FOR(i, a, b)  for(int i = (a); i < (b); i++)
#define F0R(i, a)     FOR(i, 0, a)

const ll  MOD   = 998244353;
const ll  INF   = 9e18;
const int MX    = 2e5 + 5;
const ld  PI    = acos((ld) -1);
const int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int getXOR(int BITree[], int index){
	int ans = 0;
	index += 1;
	while(index > 0){
		ans ^= BITree[index];
		index -= index & (-index);
	}
	return ans;
}

void updateBIT(int BITree[], int n, int index, int val){
	index = index + 1;
	while (index <= n){
		BITree[index] ^= val;
		index += index & (-index);
	}
}

int* constructBITree(int arr[], int n){
	int* BITree = new int[n + 1];
	for (int i = 1; i <= n; i++)
		BITree[i] = 0;
	for (int i = 0; i < n; i++)
		updateBIT(BITree, n, i, arr[i]);

	return BITree;
}

int rangeXor(int BITree[], int l, int r){
	return getXOR(BITree, r) ^ getXOR(BITree, l - 1);
}

int main(){

	int n, Q;
	cin >> n >> Q;
	int A[n + 1];
	FOR(i, 0, n) cin >> A[i];

	int q[Q][3];
	F0R(i, Q) cin >> q[i][0] >> q[i][1] >> q[i][2];

	int* BITree = constructBITree(A, n);

	for(int i = 0; i < Q; i++){
		int id = q[i][0];

		if(id == 2){
			int L = q[i][1];
			int R = q[i][2];
			cout << rangeXor(BITree, L - 1, R - 1) << "\n";
		}
		else{
			int idx = q[i][1];
			int val = q[i][2];
			A[idx - 1] ^= val;
			updateBIT(BITree, n, idx - 1, val);
		}
	}
}
