#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int MAXN = 1e5, INF = 1e9;
int n, m, vis[MAXN], dis[17][17], gems[17];
vector<int> adj[MAXN];

int bfs(int start, int find) {
	int dis = INF;
	queue<pair<int, int>> q;
	q.push({start, 0});
	vis[start] = 1;
	while(!q.empty()) {
		auto curr = q.front();
		if(curr.first == find) {
			dis = curr.second;
			break;
		}
		q.pop();
		for(int next: adj[curr.first]) {
			if(!vis[next]) {
				q.push({next, curr.second+1});
				vis[next] = 1;
			}
		}
	}
	return dis;
}

int main() {
	cin >> n >> m;
	for(int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int k;
	cin >> k;
	for(int i=0; i<k; i++) {
		cin >> gems[i];
		gems[i]--;
	}
	for(int i=0; i<k; i++) {
		for(int j=i+1; j<k; j++) {
			memset(vis, 0, sizeof(vis));
			int res = bfs(gems[i], gems[j]);
			dis[i][j] = res, dis[j][i] = res;
			if(dis[i][j] == INF) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	int dp[(1<<k)][k];
	for(int i=0; i<(1<<k); i++) {
		for(int j=0; j<k; j++) {
			dp[i][j] = INF;
		}
	}
	for(int i=0; i<k; i++) {
		dp[(1<<i)][i] = 1;
	}
	for(int i=0; i<(1<<k); i++) {
		for(int j=0; j<k; j++) {
			if(!(i>>j&1)) continue;
			for(int prev=0; prev<k; prev++) {
				if(!(i>>prev&1) || prev == j) continue;
//				cout << i << ' ' << j << ' ' << prev << endl;
				dp[i][j] = min(dp[i][j], dp[i^(1<<j)][prev]+dis[prev][j]);
			}
		}
	}
	int ans = INF;
	for(int i=0; i<k; i++) {
		ans = min(ans, dp[(1<<k)-1][i]);
	}
	cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
const int nmax=100005;
vector<vector<pair<ll,ll>>> e(nmax);
ll d[nmax];
void dijkstra(ll s){
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
  fill(d,d+nmax,INF);
  d[s]=0;
  pq.push(make_pair(0,s));
  while(!pq.empty()){
    pair<ll,ll> p=pq.top();
    pq.pop();
    ll v=p.second;
    if(d[v]<p.first){
      continue;
    }
    for(auto x:e[v]){
      if(d[x.first]>d[v]+x.second){
        d[x.first]=d[v]+x.second;
        pq.push(make_pair(d[x.first],x.first));
      }
    }
  }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<int> a(m),b(m);
    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        e[a[i]].push_back({b[i],1});
        e[b[i]].push_back({a[i],1});
    }
    int k;cin >> k;
    vector<int> c(k);
    REP(i,k){
        cin >> c[i];
        c[i]--;
    }
    vector<vector<ll>> dis(k,vector<ll>(k));
    REP(i,k){
        dijkstra(c[i]);
        REP(j,k) dis[i][j]=d[c[j]];
    }
    vector<vector<ll>> dp(1<<k,vector<ll>(k,INF));
    REP(i,k) dp[1<<i][i]=1;
    REP(t,1<<k){
        REP(i,k){
            if(dp[t][i]==INF) continue;
            if(!((t>>i)&1)) continue;
            REP(j,k){
                if((t>>j)&1) continue;
                chmin(dp[t|(1<<j)][j],dp[t][i]+dis[i][j]);
            }
        }
    }
    ll ans=INF;
    REP(i,k) chmin(ans,dp[(1<<k)-1][i]);
    cout << (ans==INF?-1:ans) << endl;
}