#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) int(x.size())
#define fk cout<<"fk"<<endl
#define db(x) cout<<(#x)<<'='<<(x)<<endl
#define db2(x,y) cout<<(#x)<<'='<<(x)<<' '<<(#y)<<'='<<(y)<<endl
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long i64;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed;}
//1.integer overflow (1e5 * 1e5) (2e9 + 2e9)
//2.runtime error
//3.boundary condition
const int N=(int)1e5+100;
const int INF=0x3f3f3f3f;
int n,m,a[N],b[N],k,c[N],dp[20][1000100],dis[20][20];
vector<int> G[N];
int main() {
    fastio();

    cin>>n>>m;
    for1(i, m){
    	cin>>a[i]>>b[i];
    	G[a[i]].eb(b[i]);
    	G[b[i]].eb(a[i]);
    }
    cin>>k;
    forn(i, k){
    	cin>>c[i];
    }
    ms(dis,-1);
    forn(i, k){
    	queue<int> q;
    	vi d(n+5,-1);
    	d[c[i]]=0;
    	q.push(c[i]);
    	while(!q.empty()){
    		int now=q.front();
    		q.pop();
    		for(int to : G[now]){
    			if(d[to]==-1){
    				d[to]=d[now]+1;
    				q.push(to);
    			}
    		}
    	}
    	forn(j, k){
    		dis[i][j]=d[c[j]];
    	}
    }
    
    ms(dp,INF);
    forn(i, k) dp[i][1<<i]=0;
    for(int i=0; i<(1<<k); ++i){
    	for(int j=0; j<k; ++j){
    		if((1<<j)&i){
    			for(int three=0; three<k; ++three){
    				if(((1<<three)&i)==0 && dis[j][three]!=-1){
    					uin(dp[three][i|(1<<three)],dp[j][i]+dis[j][three]);
    				}
    			}
    		}
    	}	
    }
    int ans=INF;
    forn(i, k) uin(ans,dp[i][(1<<k)-1]);
    cout<<(ans==INF?-1:ans+1)<<'\n';
    return 0;
}

#include <stdio.h>
#include <vector>
#include <queue>

int dist[500010];
int check[500010][20];
int x[20],y[20][20];
int c;
int func(int bit, int k)
{
	if(bit==(1<<c)-1) return 0;
	if(check[bit][k]) return check[bit][k];
	
	int ans = 1234567890;
	for(int i=1;i<=c;i++)
	{
		if((bit&(1<<(i-1)))==0)
		{
			int t = func(bit+(1<<(i-1)),i) + y[k][i];
			ans = ans<t?ans:t;
		}
	}
	return check[bit][k] = ans;
}

std::vector<int> V[100010];
std::queue<int> Q;

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=b;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		V[c].push_back(d);
		V[d].push_back(c);
	}
	
	scanf("%d",&c);
	for(int i=1;i<=c;i++) scanf("%d",&x[i]);
	for(int i=1;i<=c;i++) for(int j=1;j<=c;j++) y[i][j] = -1;
	
	for(int i=1;i<=c;i++)
	{
		for(int j=1;j<=a;j++) dist[j] = -1;
		Q.push(x[i]);
		dist[x[i]] = 0;
		while(!Q.empty())
		{
			int t = Q.front();
			Q.pop();
			for(int j=0;j<V[t].size();j++)
			{
				if(dist[V[t][j]]==-1)
				{
					dist[V[t][j]] = dist[t]+1;
					Q.push(V[t][j]);
				}
			}
		}
		for(int j=1;j<=c;j++) y[i][j] = dist[x[j]];
	}
	for(int i=1;i<=c;i++)
	{
		for(int j=1;j<=c;j++)
		{
			if(y[i][j]==-1)
			{
				printf("-1");
				return 0;
			}
		}
	}
	
	int ans = 1234567890;
	for(int i=1;i<=c;i++)
	{
		int t = func(1<<(i-1),i)+1;
		ans = ans<t?ans:t;
	}
	printf("%d",ans);
}