#include<bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include<atcoder/all>
// using namespace atcoder;
#endif
#define int long long
#define rep(i, n) for(int i = 0;i<(int)(n);i++)
#define all(v) (v).begin(),(v).end()
using lint = long long;
using ll = long long;
using P = std::pair<int,int>;

constexpr int inf = 2e18;

bool chmin(int &a,const int b) {
    if(a>b) {
        a=b;
        return true;
    }
    return false;
}

struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return false;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
        else {
            par[y] = x;
            size[x] += size[y];
        }
        return true;
    }
};

int n,m;
std::vector<int> G[100010];

int dp[300030][20];

int dis[20][20];

std::vector<int> BFS(int s) {
    std::vector<int> dist(n,inf);
    dist[s] = 0;
    std::queue<int> que;
    que.push(s);
    while(!que.empty()) {
        int v = que.front();que.pop();
        for(auto &to:G[v]) if(chmin(dist[to],dist[v]+1)) que.push(to);
    }
    return dist;
}

signed main() {
    std::cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int a,b;
        std::cin >> a >> b;
        a--,b--;
        uf.unite(a,b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int k;
    std::cin >> k;
    std::vector<int> v(k);
    rep(i, k) std::cin >> v[i],v[i]--;
    std::set<int> st;
    for(auto p:v) st.insert(uf.find(p));
    if(st.size()!=1) return !printf("-1\n");
    rep(i, k) {
        auto vec = BFS(v[i]);
        rep(j, k) dis[i][j] = vec[v[j]];
    }
    // rep(i, k) dis[k][i]=1;
    rep(i, 300030) rep(j, 20) dp[i][j]=inf;
    // dp[1<<k][k] = 0;
    // rep(i, k) rep(j, k) std::cout << dis[i][j] << " \n"[j==k-1];
    rep(i, k) dp[1<<i][i] = 1;
    rep(bit, (1<<(k+1))) {
        rep(i, k) {
            if((~bit)&(1<<i)) continue;
            // printf("OK\n");
            rep(j, k) {
                if(bit&(1<<j)) continue;
                chmin(dp[bit|(1<<j)][j],dp[bit][i]+dis[i][j]);
                // std::cout << bitset<3>(bit) << ' ' << i << ' ' << j << ' ' << std::endl;
            }
        }
    }
    // rep(i, 7) rep(j, 3) std::cout << dp[i][j] << " \n"[j==2];
    int mi = inf;
    rep(i, k) chmin(mi,dp[(1<<k)-1][i]);
    std::cout << mi << std::endl;
    return 0;
}
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
ll dp[17][100005];
int n;
V<V<int>> g;
void d(int s,int st){
       for(int i=0;i<n;i++){
            dp[s][i]=inf;
       }
       dp[s][st]=0;
       queue<int> q;
       q.emplace(st);
       while(q.size()){
           int cur=q.front();
           q.pop();
           for(int v:g[cur]){
                 if(chmin(dp[s][v],dp[s][cur]+1)){
                     q.emplace(v);
                 }
           }
       }
}
int main(){
    int m;
    cin>>n>>m;
    g=V<V<int>>(n);
    for(int i=0;i<m;i++){
          int a,b;
          cin>>a>>b;
          g[--a].emplace_back(--b);
          g[b].emplace_back(a);
    }
    int k;
    cin>>k;
    V<int> c(k);
    for(int i=0;i<k;i++){
        cin>>c[i];
        c[i]--;
        d(i,c[i]);
        //for(int j=0;j<n;j++)cout<<dp[i][j]<<" ";
        //cout<<"\n";
    }
    V<V<ll>> res((1<<k)+5,V<ll>(k+1,inf));
    for(int i=0;i<k;i++)res[(1<<i)][i]=1;
    for(int s=0;s<(1<<k);s++){
        for(int i=0;i<k;i++){
             if(~s&(1<<i))continue;
             for(int j=0;j<k;j++){
                 if(s&(1<<j))continue;
                 chmin(res[s|(1<<j)][j],res[s][i]+dp[i][c[j]]);
             } 
        }
    }
    ll ans=inf;
    for(int i=0;i<k;i++)chmin(ans,res[(1<<k)-1][i]);
    cout<<(ans>=inf?-1:ans)<<"\n";
}