#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll INF = 1e15;
ll n, m, k;

ll dp[1 << 17][20];

ll helper(vector<vector<ll>>& adj, ll from, ll to)
{
    queue<ll> q;
    q.push(from);
    ll ret = 0;
    vector<bool> visited(n + 1, false);
    visited[from] = true;
    while(!q.empty())
    {
        ret++;
        ll sz = q.size();
        while(sz--)
        {
            auto t = q.front();
            q.pop();
            for(auto nt : adj[t])
            {
                if(visited[nt])
                    continue;
                visited[nt] = true;
                if(nt == to)
                    return ret;
                q.push(nt);
            }
        }
    }
    return INF;
}

ll helper2(vector<vector<ll>>& dist, ll idx, ll status)
{
    if(status == ((1 << k) - 1))
        return 0;
    if(dp[status][idx] != -1)
        return dp[status][idx];
    
    ll ret = INF;
    for(ll i = 0; i < k; i++)
    {
        if(!((status >> i) & 1))
        {
            ll can = dist[idx][i] + helper2(dist, i, status | (1 << i));
            ret = min(ret, can);
        }
    }
    dp[status][idx] = ret;
    return ret;
}

ll mst(vector<vector<ll>>& dist)
{
    ll ret = INF;
    memset(dp, -1, sizeof(dp));
    for(ll i = 0; i < k; i++)
    {
        ll status = (1 << i);
        ll can = helper2(dist, i, status);
        ret = min(ret, can);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    vector<vector<ll>> adj(n + 1);
    ll a, b;
    for(ll i = 0; i < m; i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    cin >> k;
    vector<ll> c(k);
    for(ll i = 0; i < k; i++)
        cin >> c[i];
    
    vector<vector<ll>> dist(k, vector<ll>(k, 0));
    for(ll i = 0; i < k; i++)
    {
        for(ll j = i + 1; j < k; j++)
        {
            ll num = helper(adj, c[i], c[j]);
            if(num >= INF)
            {
                cout << -1 << endl;
                return 0;
            }
            dist[i][j] = num;
            dist[j][i] = num;
        }
    }

    cout << mst(dist) + 1 << endl;
    
    return 0;
}



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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> e(n), er(n);
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        e[a[i]].push_back(b[i]);
        er[b[i]].push_back(a[i]);
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        vector<int> vis(n, 0);
        vis[i] = 1;
        queue<int> q;
        for(int j=0; j<e[i].size(); j++){
            q.push(e[i][j]);
        }
        while(!q.empty()){
            int v = q.front();
            q.pop();
            if(vis[v]) continue;
            vis[v] = 1;
            for(int k=0; k<e[v].size(); k++){
                if(!vis[e[v][k]]) q.push(e[v][k]);
            }
        }
        for(auto v: vis){
            ans += v;
        }
    }
    cout << ans << endl;

    return 0;
}