#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <typename T>
T mypow(T x, T n, const T &p = -1)
{ //x^nをmodで割った余り
	T ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
// using namespace atcoder;

struct edge{
	int to,cost;
	edge(int a,int b):to(a),cost(b){}
};

vector<int> dijkstra(vector<vector<edge>> &g,int s){
	constexpr int inf=5e5;
	vector<int>dis(g.size(),inf);
	dis[s]=0;
	using P=pair<int,int>;
	priority_queue<P,vector<P>,greater<P>>pq;
	pq.emplace(0,s);
	while(!pq.empty()){
		auto p=pq.top();
		pq.pop();
		int d=p.first;
		int v=p.second;
		if(d>dis[v])continue;
		for(auto x:g[v]){
			if(chmin(dis[x.to],dis[v]+x.cost)){
				pq.emplace(dis[x.to],x.to);
			}
		}
	}

	return dis;
}

void solve()
{
	int n,m;
	cin>>n>>m;
	vector<vector<edge>>g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].eb(b,1);
		g[b].eb(a,1);
	}
	int k;
	cin>>k;
	vector<int>c(k);
	rep(i,k)cin>>c[i],c[i]--;
	vector<vector<int>>dis(k);
	rep(i,k){
		dis[i]=dijkstra(g,c[i]);
	}

	constexpr int inf=5e5;
	vector<vector<int>>dp((1<<k)+5,vector<int>(k,inf));
	rep(i,k)dp[1<<i][i]=1;

	rep(bit,1<<k){
		rep(i,k){
			if(dp[bit][i]==inf)continue;
			rep(j,k){
				if(bit&(1<<j))continue;

				chmin(dp[bit|1<<j][j],dp[bit][i]+dis[i][c[j]]);
			}
		}
	}

	int ans=inf;
	rep(i,k){
		chmin(ans,dp[(1<<k)-1][i]);
	}
	if(ans==inf)cout<<-1;
	else cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<stack>
using namespace std;
vector<int> g[100000];
int flag[100000];
int dis[17][100000];
int D[17][17];
int cost[17][131072];
int bin[18];
int DP(int v, int s);
int n, m, k;
int main() {
	/*
	int bin[17];
	bin[0] = 1;
	int i, j;
	for (i = 1; i <= 16; i++)bin[i] = bin[i - 1] * 2;

	int n, m, k;
	cin >> n >> m;
	int a[101], b[101], c[16], d[16];
	for (i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}
	cin >> k;
	for (i = 0; i < k; i++) {
		cin >> c[i] >> d[i];
	}
	int sara[101], MAX = 0, counter;
	for (i = 0; i < bin[k]; i++) {
		//cout << i << endl;
		for (j = 0; j <= 100; j++)sara[j] = 0;
		counter = 0;
		for (j = 0; j < k; j++) {
			if (i + bin[j] != (i ^ bin[j])) {
				sara[c[j]] = 1;
			}
			else {
				sara[d[j]] = 1;
			}
		}
		for (j = 0; j < m; j++) {
			if (sara[a[j]] == 1 && sara[b[j]] == 1) {
				counter++;
			}
		}
		MAX = max(counter, MAX);
	}
	cout << MAX << endl;
	return 0;
	*/

	/*long long int n, i, x, y;
	cin >> n;
	long long int counter = 0;
	for (i = 1; i * i <= 2 * n; i++) {
		if ((2 * n) % i == 0) {
			x = i;
			y = 2 * n / i;
			if (x % 2 != y % 2) {
				counter++;

			}
		}
		
	}
	cout << counter * 2		<< endl;
	return 0;
	*/

	memset(cost, -1, sizeof(cost));
	cin >> n >> m;

	int a, b, i, j;
	bin[0] = 1;
	for (i = 1; i <= 17; i++)bin[i] = bin[i - 1] * 2;
	for (i = 0; i < m ; i++) {
		
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cin >> k;
	int c[20];
	for (i = 0; i < k; i++) {
		cin >> c[i];
		c[i]--;
	}
	int p;
	queue<int> que;
	que.push(c[0]);
	flag[c[0]] = 1;
	while (que.size()) {
		p = que.front(); que.pop();
		for (i = 0;i < g[p].size(); i++) {
			if (flag[g[p][i]] == 0) {
				flag[g[p][i]] = 1;
				que.push(g[p][i]);
			}

		}
	}
	for (i = 0; i < k; i++) {
		if (flag[c[i]] == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (i = 0; i < k; i++) {
		dis[i][c[i]] = 0;
		que.push(c[i]);
		while (que.size()) {
			p = que.front(); que.pop();
			for (j = 0; j < g[p].size(); j++) {
				if (dis[i][g[p][j]] == 0 && g[p][j] != c[i]) {
					dis[i][g[p][j]] = dis[i][p] + 1;
					que.push(g[p][j]);
					//cout << dis[i][g[p][j]] << endl;
				}
			}
		}
	}
	for (i = 0; i < k; i++) {
		for (j = 0; j < k; j++) {
			D[i][j] = dis[i][c[j]];
		}
	}

	int MIN = 99999999;
	for (i = 0; i < k; i++) {
		//cout << i << endl;
		MIN = min(MIN, DP(i, bin[k] - 1 - bin[i]));

	}
	cout << MIN + 1 << endl;
	return 0;

}

int DP(int v, int s) {
	//cout << s << endl;
	if (cost[v][s] != -1) {
		return cost[v][s];
	}
	if (s == 0) {
		cost[v][s] = 0;
		return 0;
	}
	int ii, MIN = 99999999;
	for (ii = 0; ii < k; ii++) {
		if ((s ^ bin[ii]) != (s + bin[ii])) {
			//cout << s - bin[v] << endl;
			MIN = min(MIN, DP(ii, s - bin[ii]) + D[v][ii]);

		}
	}

	cost[v][s] = MIN;
	return MIN;


}