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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  vector<vector<int32>> adj(n);
  REP(i,m){
    int32 a,b;
    cin >> a >> b;
    --a;--b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  int32 k;
  cin >> k;
  vector<int32> c(k);
  REP(i,k){
    cin >> c[i];
    --c[i];
  }
  vector<vector<int32>> g(k,vector<int32>(k,inf));
  REP(i,k){
    vector<int32> dist(n,inf);
    queue<pii> que;
    auto push = [&](int32 d,int32 v){
      if(chmin(dist[v],d))
        que.emplace(d,v);
    };
    push(0,c[i]);
    while(!que.empty()){
      auto [d,v] = que.front();que.pop();
      if(d != dist[v])continue;
      for(auto u : adj[v]){
        push(d+1,u);
      }
    }
    REP(j,k){
      g[i][j] = dist[c[j]];
    }
  }
  // REP(i,k){
  //   REP(j,k){
  //     cout << g[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  vector<vector<int32>> dist(k,vector<int32>(1<<k,inf));
  queue<pair<int32,pii>> que;
  auto push = [&](int32 d, int32 v, int32 s){
    if(chmin(dist[v][s],d))
      que.emplace(d,pii(v,s));
  };
  REP(i,k){
    push(0,i,1<<i);
  }
  while(!que.empty()){
    auto [d,p] = que.front();que.pop();
    auto [v,s] = p;
    if(dist[v][s] != d)continue;
    REP(u,k){
      if(u == v)continue;
      if(g[v][u] == inf)continue;
      push(d+g[v][u],u,s|(1<<u));
    }
  }
  int32 ans = inf;
  REP(i,k){
    chmin(ans,dist[i][(1<<k)-1]);
  }
  if(ans == inf){
    ANS(-1);
  }else{
    ANS(ans+1);
  }
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define pb push_back
#define mp make_pair

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX_N = 2e5+10;
const int MAX_K = 19;

int n, m;
int a[MAX_N],b[MAX_N];
int k;
int c[MAX_K];
int dist[MAX_K][MAX_N];
int dp[1<<MAX_K][MAX_K];
vector<int> g[MAX_N];

void bfs(int s)
{
	int* D = dist[s];
	D[c[s]] = 0;
	queue<int> que;
	que.push(c[s]);
	while(!que.empty()){
		int cur = que.front(); que.pop();
		for(int t : g[cur]){
			if(D[t]>D[cur]+1){
				D[t]=D[cur]+1;
				que.push(t);
			}
		}
	}
}

void solve()
{
	for(int i=0;i<m;++i){
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	memset(dist,0x3f,sizeof(dist));
	for(int i=0;i<k;++i) bfs(i);
	memset(dp, 0x3f, sizeof(dp));
	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(dp[i][j]!=INF){
		for(int x=0;x<k;x++)if(!(i>>x&1)){ // adding x
			const int d=dist[j][c[x]];
			if(d != INF){
				dp[i|(1<<x)][x]=min(dp[i|(1<<x)][x],dp[i][j]+d);
			}
		}
	}
	int ans = INF;
	for(int i=0;i<k;++i)ans=min(ans,dp[(1<<k)-1][i]);
	if(ans==INF)ans=-1;
	cout<<ans<<'\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i=0;i<m;++i){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	cin >> k;
	for(int i=0;i<k;++i){
		cin>> c[i];
		c[i]--;
	}
	solve();
	return 0;
}