/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef int ll;
const int N=10,M=1e5+10;

int n,m;
int wei[N],id[N];
ll f[N];
pair<int,int> bri[M]; //(limit,length)

inline int Read(int &r){
	int b=1,c=getchar();r=0;
	while(c<'0' || '9'<c) b=c=='-'? -1:b,c=getchar();
	while('0'<=c && c<='9') r=(r<<1)+(r<<3)+(c^'0'),c=getchar();
	return r*=b;
}
int Query(int tot){
	int le=0,ri=m;
	while(le+1<ri){
		int mi=(le+ri)>>1;
		if(bri[mi].first<tot) le=mi;
		else ri=mi;
	}
	if(bri[ri].first<tot) return bri[ri].second;
	return bri[le].second;
}
int main(){
	Read(n),Read(m);
	int minbri=1e8,maxwei=0;
	for(int i=1;i<=n;i++) maxwei=max(maxwei,Read(wei[i])),id[i]=i;
	for(int i=1;i<=m;i++){
		Read(bri[i].second);
		minbri=min(minbri,Read(bri[i].first));
	}
	if(minbri<maxwei){
		printf("-1\n");
		return 0;
	}
	sort(bri+1,bri+1+m);
	for(int i=2;i<=m;i++)
		bri[i].second=max(bri[i].second,bri[i-1].second);
	ll ans=(ll)1e18;
	do{
		for(int i=1;i<=n;i++) f[i]=0;
		for(int i=1;i<=n;i++){
			int tot=wei[id[i]];
			for(int j=i+1;j<=n;j++){
				tot+=wei[id[j]];
				f[j]=max(f[j],f[i]+Query(tot));
			}
		}
		ans=min(ans,f[n]);
	}while(next_permutation(id+1,id+1+n));
	printf("%d\n",ans);
	return 0;
}
#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;
}