#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
const int MOD=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>> G(N,vector<int>());
  for(int i(0);i<M;i++){
    int a,b; cin>>a>>b; a--;b--;
    G[a].push_back(b); G[b].push_back(a);
  }
  int K; cin>>K;
  vector<int> C(K);
  for(int i(0);i<K;i++){
    cin>>C[i]; C[i]--;
  }
  vector<vector<int>> d(K, vector<int>(N,INFint));
  for(int k(0);k<K;k++){
    queue<int> q;
    d[k][C[k]] = 0;
    q.push(C[k]);
    while(!q.empty()){
      int v = q.front();q.pop();                                                  
      for (int next: G[v]){
        if(d[k][next] == INFint){
          d[k][next] = d[k][v] + 1;
          q.push(next);
        }
      }
    }
  }
  int ans(INFint);
  vector<vector<int>> dp(1<<K,vector<int>(K,INFint));
  for(int i(0);i<K;i++) dp[1<<i][i] = 0;
  for(int i(1);i<(1<<K);i++){
    for(int j(0);j<K;j++){
      if(i&(1<<j)){ // iのなかにjが入っている時のみ考える(jが通過していないパターンは矛盾しているのであり得ない)
        for(int k(0);k<K;k++){
          dp[i][j] = min(dp[i][j], dp[i-(1<<j)][k]+ d[k][C[j]]); //集めるdpでkからjにくるパターンを考えている
        }
      }
    }
  }
  for(int i(0);i<K;i++) ans = min(ans, dp[(1<<K)-1][i]);
  if(ans == INFint) cout << -1 << endl;
  else cout << ans+1 << endl;
  return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long
//using mint = atcoder::modint;

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i,0,M) cin >> A[i] >> B[i];
    int K;
    cin >> K;
    vector<int> C(K);
    rep(i,0,K) cin >> C[i];
    vector<vector<int>> edges(N+1);
    rep(i,0,M) {
        edges[A[i]].emplace_back(B[i]);
        edges[B[i]].emplace_back(A[i]);
    }
    vector<vector<int>> distances(K, vector<int>(K, INT_MAX));
    rep(i,0,K) {
        vector<int> distances_(N+1, INT_MAX);
        priority_queue<pair<int, int>, vector<pair<int,int>>, greater<>> q;
        q.push({0, C[i]});
        distances_[C[i]] = 0;
        while (!q.empty()) {
            auto [cost, current] = q.top();
            q.pop();
            for (const auto& next : edges[current]) {
                if (distances_[next] > cost + 1) {
                    distances_[next] = cost + 1;
                    q.push({distances_[next], next});
                }
            }
        }
        rep(j,0,K) {
            if (distances_[C[j]] == INT_MAX) {
                cout << -1 << endl;
                return 0;
            }
            distances[i][j] = distances_[C[j]];
        }
    }
    vector<vector<int>> dp(1 << K, vector<int>(K, INT_MAX));
    rep(i,0,K) dp[1<<i][i] = 1;
    rep(i,1,1<<K) rep(j,0,K) {
        if(dp[i][j] == INT_MAX) continue;
        rep(k,0,K) {
            dp[i | 1<<k][k] = min(dp[i | 1<<k][k], dp[i][j] + distances[j][k]);
        }
    }
    cout << *min_element(all(dp[(1<<K) - 1])) << endl;
    return 0;
}
