#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int maxm=3e5+10;
int head[maxn],w[maxm],dis[20][maxn],nt[maxm],to[maxm],tot;
int cnt[maxn],d[maxn],vis[maxn];int n,m,c[maxn];
void add(int x,int y,int z)
{
	to[++tot]=y;w[tot]=z;nt[tot]=head[x];head[x]=tot;
}
bool spfa(int p)
{
	for(int i=1;i<=n;i++)	dis[p][i]=1e9;
	memset(vis,0,sizeof vis);
	queue<int> q;
	while(q.size())	q.pop();
	dis[p][c[p]]=0;vis[c[p]]=true;q.push(c[p]);
	while(q.size()){
		int x=q.front();q.pop();vis[x]=false;
		for(int i=head[x];i;i=nt[i]){
			int y=to[i],z=w[i];
			//cout<<dis[y]<<" "<<dis[x]+z<<endl;
			if(dis[p][y]>dis[p][x]+z){
				dis[p][y]=dis[p][x]+z;
				if(!vis[y])	q.push(y),vis[y]=true;
			}
		}
	}
	return true;
}
int dp[1<<18][20];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int t1,t2;scanf("%d%d",&t1,&t2);
		add(t1,t2,1);add(t2,t1,1);
	}
	int k;scanf("%d",&k);
	for(int i=0;i<k;i++)
		scanf("%d",&c[i]),spfa(i);
	int ans=1e9;memset(dp,0x3f,sizeof dp);
	for(int i=0;i<k;i++)
		dp[1<<i][i]=1;
	for(int s=1;s<(1<<k);s++){
		for(int i=0;i<k;i++){
			if(s&(1<<i)){
				;
			}else continue;
			for(int j=0;j<k;j++){
				if(i==j)	continue;
				if(s&(1<<j));else	continue;
				dp[s][j]=min(dp[s][j],dp[s^(1<<j)][i]+dis[i][c[j]]);
			}
		}
	}
	for(int i=0;i<k;i++)
		ans=min(ans,dp[(1<<k)-1][i]);
	if(ans==1e9)	cout<<"-1"<<endl;
	else
		cout<<ans<<endl;
}
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define li long long
#define pii pair<int, int>
#define vi vector<int>
#define li long long

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

const int MAXK = 17;
const int MAXN = 1e5+5;
const int INF = 1e9;

vi edges[MAXN];
int dp[(1 << MAXK)][MAXK];
int d[MAXK][MAXN];

void upd(int& x, int y) {
	x = min(x, y);
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	forn(i, m) {
		int x, y;
		scanf("%d%d", &x, &y);
		edges[x].pb(y);
		edges[y].pb(x);
	}	
	int k;
	scanf("%d", &k);
	vi chosen(k);
	forn(i, k) {
		scanf("%d", &chosen[i]);
	}
	forn(i, k) {
		queue<int> q;
		q.push(chosen[i]);
		fore(v, 1, n) {
			d[i][v] = INF;
		}
		d[i][chosen[i]] = 0;
		while(!q.empty()) {
			int v = q.front();
			q.pop();
			for (int u : edges[v]) {
				if (d[i][u] == INF) {
					d[i][u] = d[i][v] + 1;
					q.push(u);
				}
			}
		}
	}
	/*forn(i, k) {
		fore(j, 1, n) {
			printf("d[%d][%d] = %d\n", i, j, d[i][j]);
		}
	}*/
	forn(mask, (1 << k))
		forn(last, k)
			dp[mask][last] = INF;
	forn(j, k) {
		dp[(1 << j)][j] = 1;
	}
	forn(mask, (1 << k)) {
		forn(last, k) {
			if (dp[mask][last] == INF) {
				continue;
			}
			forn(next, k) {
				if (!(mask & (1 << next)) && d[last][chosen[next]] != INF) {
					upd(dp[mask | (1 << next)][next], dp[mask][last] + d[last][chosen[next]]);
				}
			}
		}
	}
	int ans = INF;
	forn(last, k) {
		ans = min(ans, dp[(1 << k) - 1][last]);
	}
	if (ans == INF) {
		ans = -1;
	}
	printf("%d", ans);
}