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

int N, M, K;
int dis[18][100001];
int c[18];
vector<int> g[100001];
const int ALL = (1 << 18) - 1;
const int INF = 1000000;
int dp[ALL + 1][18];

int solve(int mask, int last) {
    if (dp[mask][last] != -1) {
        return dp[mask][last];
    }

    int & res = dp[mask][last];
    res = INF; 
    if (mask == ((1 << K) - 1)) {
        // cout << mask << endl;
        res = 0;
        return res;
    }

    for (int i = 0; i < K; ++i) {
        if (mask == 0) {
            res = min(res, 1 + solve(mask | (1 << i), i));
            continue;
        }

        // haven't included it yet
        if (((1 << i) & mask) == 0) {
            int d = dis[last][c[i]];
            if (d >= 0) res = min(res, d + solve(mask | (1 << i),  i));
            // cout << c[last] << " " << c[i] << " " << dis[c[last]][c[i]] << " " << res << endl;
        }
    }

    return res;
}

void getDis(int i) {
    int s = c[i];
    queue<int> q;
    q.push(s);
    dis[i][s] = 0;

    while (!q.empty()) {
        int u = q.front();
        q.pop();
        int d = dis[i][u];

        for (int v : g[u]) {
            if (dis[i][v] == -1) {
                dis[i][v] = d + 1;
                q.push(v);
            }
        }
    }
}

int main() {
    memset(dis, -1, sizeof dis);
    memset(dp, -1, sizeof dp);
    cin >> N  >> M;
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cin >> K;
    for (int i = 0; i < K; ++i) {
        cin >> c[i];
        getDis(i);
    }
    // cout << dis[1][3] << endl;
    int res = solve(0, 0);
    if (res == INF) {
        cout << "-1\n";
    } else {
        cout << res << "\n";
    }

    return 0;
}
#include <bits/stdc++.h>
    using namespace std;
    #define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define pb push_back
    #define ll long long
     
    #define vi vector<int>
    #define vll vector<long long>
    #define mp make_pair 
    #define infi INT_MAX
    #define infl LONG_LONG_MAX
    #define infd LDBL_MAX
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define ff first
    #define ss second
    #define pll pair<ll,ll> 
    #define INF 1999999996000000010
    #define endl "\n"
    #define ALL(v) v.begin(),v.end()
    #define nl cout<<"\n";
    #define pr(x) cout<<x;
    #define pr1(x) cout<<x<<" ";
    #define pr2(x,y) cout<<x<<" "<<y;
    #define deb printf("*****************************\n");
    #define idk printf("idk idk ! \n");
    #define hi printf("hi ! \n");
    #define bye printf("bye bye ! \n");
    #define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
    #define number_of_set_bits  __builtin_popcountll  
     
    //template<typename T>
    //#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
    //member functions :
    //1. order_of_key(k) : number of elements strictly lesser than k
    //2. find_by_order(k) : k-th element in the set
     
 vll v[300005];    
 ll dp[20][(1ll<<18)];
 ll d[20][300005]; 
 ll k;
 
 
 
 void dijkstra(ll src,ll idx){
  queue<ll> q;
  q.push(src);
  d[idx][src]=0;
  while(!q.empty()){
    ll elem = q.front();
    q.pop();
    for(auto itr : v[elem]){
      if(d[idx][itr]!=INF) continue;
      d[idx][itr]=d[idx][elem]+1;
      q.push(itr);
    }
  }
}

 
 
 ll fun(ll nodeidx, ll mask, vll& p) {
     if(mask == (1ll<<k) - 1) return 0;
     else if(dp[nodeidx][mask] != -1)  return dp[nodeidx][mask];
     
     ll ans = 1e9;
     for(int i = 0; i <k; ++i) { 
        if(mask&(1ll<<i)) continue; 
        { 
             ll cost = d[nodeidx][p[i]] + fun(i, mask|(1ll<<i), p );
             ans = min(ans,cost);
        }
     }
     return  dp[nodeidx][mask] = ans;
 }
 
int main(){
    fast
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
        
     
    ll ntc=1;     
    f(ks,1,ntc+1)
    {

      ll n,m; cin>>n>>m;
      f(i,0,n+3) v[i].clear();
      f(i,0,m){
          ll a,b; cin>>a>>b;
          v[a].pb(b);
          v[b].pb(a);
    
      }
    
     cin>>k;
     vll p(k);
     f(i,0,k) cin>>p[i];
     
     bool ok = true;


     f(i,0,k){
        f(j,0,n+1) d[i][j]=INF;
     }
     
     f(i,0,k){
         dijkstra(p[i],i);
         f(j,0,k) {
             if(d[i][p[j]] == INF) ok = false;
         }  
     }

    //  f(i,0,k){
    //     f(j,1,n+1) cout<<d[i][j]<<" ";
    //     cout<<endl;
    // }


    if(ok == false) cout<<-1<<endl;
    else  {
        ll ans = LLONG_MAX; 
        memset(dp,-1,sizeof dp);    
        for(int i = 0; i <k; ++i){
            ll mask = (1<<i);
            ll here = fun(i, mask, p);
            ans = min(ans,here);
        } 
        cout<<ans + 1<<endl;            
    }
     
      
  }
     
        return 0;
}