//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define up upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,m,k;
vector<int> al[100005];
int arr[20];

int mat[20][20];

int w[100005];
queue<int> q;

ll memo[132000][17];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n>>m;
	
	int a,b;
	rep(x,0,m){
		cin>>a>>b;
		al[a].pub(b);
		al[b].pub(a);
	}
	
	cin>>k;
	rep(x,0,k) cin>>arr[x];
	
	rep(x,0,k){
		memset(w,63,sizeof(w));
		w[arr[x]]=0;
		q.push(arr[x]);
		
		while (!q.empty()){
			int node=q.front();
			q.pop();
			
			for (auto &it:al[node]){
				if (w[it]>1e9){
					w[it]=w[node]+1;
					q.push(it);
				}
			}
		}
		
		rep(y,0,k){
			mat[x][y]=w[arr[y]];
		}
	}
	
	//rep(x,0,k) cout<<mat[0][x]<<" "; cout<<endl;
	
	memset(memo,63,sizeof(memo));
	rep(x,0,k){
		memo[1<<x][x]=0;
	}
	
	rep(x,1,1<<k) rep(y,0,k){
		rep(bit,0,k) if ((x&(1<<bit))==0){
			memo[x|(1<<bit)][bit]=min(memo[x|(1<<bit)][bit],memo[x][y]+mat[y][bit]);
		}
	}
	
	//rep(x,0,k) cout<<memo[(1<<k)-1][x]<<" "; cout<<endl;
	
	ll ans=1e10;
	rep(x,0,k) ans=min(ans,memo[(1<<k)-1][x]);
	
	if (ans>1e9) cout<<"-1"<<endl;
	else cout<<ans+1<<endl;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> w(n);
    rep(i,n)cin >> w[i];
    sort(w.begin(), w.end());

    vector<P> vl(m);
    rep(i,m) cin >> vl[i].second >> vl[i].first;
    sort(vl.begin(),vl.end());
    rep(i,m-1){
        vl[i+1].second = max(vl[i+1].second, vl[i].second); //lでマックスとっていく
    }
    vector<int> v(m);
    rep(i,m) v[i] = vl[i].first;

    int w_max = *max_element(w.begin(), w.end());
    int v_min = *min_element(v.begin(), v.end());
    if(w_max>v_min){
        cout << -1 << endl;
        return 0;
    }

    //順列全探索
    ll ans = LINF;
    do{
        vector<int> sum_w(n+1, 0);
        rep(i, n) sum_w[i+1] = sum_w[i] + w[i];

        //ここから有向グラフ化
        //i→j間は、i~jのラクダたちが含まれるので重さの総和でにぶたんして辺の長さを決める
        vector<vector<P>> edge(n, vector<P>(0));
        //i,jは1-indexed
        for(int i=1;i<n;i++){
            for(int j=i+1;j<=n;j++){
                int weight = sum_w[j]-sum_w[i-1];
                auto itr = lower_bound(vl.begin(), vl.end(), make_pair(weight, 0));
                if(itr==vl.begin())
                    edge[i-1].emplace_back(j-1, 0); //edgeは0-indexed
                else
                    edge[i-1].emplace_back(j-1,vl[itr-vl.begin()-1].second);
            }
        }
        //bfsで距離調べる
        queue<int> q;
        q.push(0);
        vector<int> dist(n, -1);
        dist[0] = 0;
        while(!q.empty()){
            int p = q.front();
            q.pop();
            for(auto c :edge[p]){
                if(dist[c.first]!=-1){
                    dist[c.first] = max(dist[c.first], dist[p] + c.second);
                    continue;
                }
                q.push(c.first);
                dist[c.first] = dist[p] + c.second;
            }
        }
        ll res = dist[n-1];
        ans = min(ans, res);
    }while(next_permutation(w.begin(), w.end()));
    cout << ans << endl;
    return 0;
}