#include<bits/stdc++.h>

using namespace std;
const int inf = 1e9;

bool mini(int &a, int b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt","r",stdin);
    int n, m; cin >> n >> m;
    vector<vector<int> > adj(n);
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int k; cin >> k;
    vector<int> c(k);
    for (int i = 0; i < k; i++) {
        cin >> c[i];
        --c[i];
    }
    auto bfs = [&](int s) {
        vector<int> cost(n, inf);
        cost[s] = 0;
        queue<int> q;
        q.push(s);
        while (q.size()) {
            int u = q.front();
            q.pop();
            for (int v: adj[u]) {
                if (mini(cost[v], cost[u] + 1)) q.push(v);
            }
        }
        for (int i = 0; i < k; i++) cost[i] = cost[c[i]];
        cost.resize(k);
        return cost;
    };
    vector<vector<int> > cost(k);
    for (int i = 0; i < k; i++) cost[i] = bfs(c[i]);
    vector<vector<int> > dp(1 << k, vector<int>(k, inf));
    for (int i = 0; i < k; i++) dp[1 << i][i] = 1;
    for (int mask = 1; mask < (1 << k); mask++) {
        for (int i = 0; i < k; i++) {
            if (mask & (1 << i)) {
                int mask2 = mask ^ (1 << i);
                for (int j = 0; j < k; j++) {
                    if (mask2 & (1 << j)) {
                        mini(dp[mask][i], dp[mask2][j] + cost[i][j]);
                    }
                }
            }
        }
    }
    int ans = *min_element(dp.back().begin(), dp.back().end());
    if (ans >= inf) ans = -1;
    cout << ans;
    return 0;
}
#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using pii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define pi 3.14159265358979
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) int x;cin >> x
#define cci(x,y) int x,y;cin >> x >> y
#define co(x) cout << x << endl
void chmax(int &x,int y){x=max(x,y);}
void chmin(int &x,int y){x=min(x,y);}

int main(){
  cci(n,m);
  int inf=1001001001;
  vvi to(n,vi(0));

  rep(i,0,m){
    cci(a,b);
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  cii(r);
  vi v(r);
  rep(i,0,r)ci(v[i]),v[i]--;

  vvi dist(r,vi(r));
  // rep(i,0,n)dist[i][i]=0;
  rep(i,0,r){
    int now=v[i];
    vi dis(n,inf);
    dis[now]=0;
    queue<int> q;
    q.push(now);
    while(!q.empty()){
      int x=q.front();q.pop();
      for(int nx:to[x]){
        if(dis[nx]==inf){
          dis[nx]=dis[x]+1;
          q.push(nx);
        }
      }
    }
    rep(j,0,r)dist[i][j]=dis[v[j]];
  }

  // rep(k,0,r){
  //   rep(i,0,r){
  //     rep(j,0,r){
  //       int I=v[i],J=v[j],K=v[k];
  //       chmin(dist[I][J],dist[I][K]+dist[K][J]);
  //     }
  //   }
  // }

  int r2=1<<r;
  vvi dp(r2,vi(r,inf));
  rep(i,0,r)dp[1<<i][i]=0;
  rep(bn,0,r2){
    rep(i,0,r){
      if(~bn>>i&1)continue;
      rep(j,0,r){
        if(bn>>j&1)continue;
        chmin(dp[bn|1<<j][j],dp[bn][i]+dist[i][j]);
      }
    }
  }

  int ans=inf;
  rep(i,0,r)chmin(ans,dp[r2-1][i]);
  if(ans==inf)ans=-2;
  co(++ans);
}