#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;


const ll INF = 2e18 + 100;
const int MOD1 = 998244353;
const int MOD = 1e9 + 7;
const int N = 135000;
const int SIZE = 30100;
const int LOG = 21;
const int K = 18;

vector<vector<int> > gr;
vector<vector<int> > dist;
vector<int> c;
int n, m, k;

void bfs(int st, int ind) {
    queue<int> q;
    vector<int> d(n, INF);

    d[st] = 0;
    q.push(st);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : gr[v]) {
            if (d[u] == INF) {
                d[u] = d[v] + 1;
                q.push(u);
            }
        }
    }
    for (int i = 0; i < k; i++) {
        dist[ind][i] = d[c[i]];
    }
}

int dp[K][N];

signed main() {
#ifdef hedgehog
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    cin >> n >> m;
    gr.resize(n);
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--; u--;
        gr[v].push_back(u);
        gr[u].push_back(v);
    }
    cin >> k;
    c.resize(k);
    for (int &i : c) cin >> i;
    for (int &i : c) i--;
    dist.resize(k, vector<int>(k));
    for (int i = 0; i < k; i++) {
        bfs(c[i], i);
    }
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < N; j++) {
            dp[i][j] = INF;
        }
    }
    for (int i = 0; i < k; i++) {
        dp[i][1 << i] = 1;
    }
    for (int mask = 1; mask < (1 << k); mask++) {
        for (int v = 0; v < k; v++) {
            if (dp[v][mask] == INF) continue;
            //cout << v << ' ' << mask << '\n';
            for (int u = 0; u < k; u++) {
                if (((mask >> u) & 1) == 0) {
                    //cout << v << ' ' << u << ' ' << dist[v][u] << '\n';
                    dp[u][mask + (1 << u)] = min(dp[u][mask + (1 << u)], dp[v][mask] + dist[v][u]);
                }
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < k; i++) {
        ans = min(ans, dp[i][(1 << k) - 1]);
    }
    if (ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';

}







#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)

vector <int> dy = {0, 1, 0, -1};
vector <int> dx = {1, 0, -1, 0};

const int INF = 1000000000;
const ll INFLL = 100000000000000000;

int main(){
    int n; cin >> n;
    int m; cin >> m;

    vector <vector<int>> G(n);
    rep(i, m){
        int a, b; cin >> a >> b;
        a --;
        b --;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }

    int k; cin >> k;
    vector <int> is_v(n);
    vector <int> is_zip(n, -1);
    rep(i, k){
        int c; cin >> c;
        c --;
        is_v.at(c) = 1;
        is_zip.at(c) = i;
    }

    //各i,jについてc_i ~ c_jの最短距離を求める
    vector <vector <int>> dist(k, vector<int>(k, INF));
    for(int i = 0; i < n; i ++){
        if(is_v.at(i) == 0) continue;
        deque <pair<int, int>> d; d.push_back(make_pair(i, 0));
        vector <int> seen(n, -1); seen.at(i) = 1;
        while(d.size()){
            auto p = d.front();
            d.pop_front();
            int now = p.first;
            int cost = p.second;
            if(is_v.at(now) != 0){
                dist.at(is_zip.at(i)).at(is_zip.at(now)) = min(dist.at(is_zip.at(i)).at(is_zip.at(now)), cost);
            }
            for(auto next: G.at(now)){
                if(seen.at(next) != -1) continue;
                int next_cost = cost + 1;
                seen.at(next) = 1;
                d.push_back(make_pair(next, next_cost));
            }
        }
    }

    // for(int i = 0; i < k; i ++){
    //     rep(j, k){
    //         //dist.at(i).at(j) ++;
    //         cout << dist.at(i).at(j) << "  ";
    //     }
    //     cout << endl;
    // }

    //求めた距離から巡回セールスマンを行う
    vector <vector <int>> dp((1 << k), vector<int>(k, INF));
    rep(i, k){
        dp.at((1 << i)).at(i) = 1;
    }
    rep(s, (1 << k)){
        if(s == 0) continue;
        rep(i, k){
            if(!((s >> i) & 1)) continue;
            int tmp = INF;
            rep(j, k){
                tmp = min(tmp, dp.at(s ^ (1 << i)).at(j) + dist.at(j).at(i));
            }
            //cout << tmp << endl;
            dp.at(s).at(i) = min(dp.at(s).at(i), tmp);
        }
    }

    int ans = INF;
    for(auto tmp: dp.at((1 << k) - 1)) ans = min(ans, tmp);
    if(ans == INF){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;


// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('joshima', 'tokio', 'nara', 'o',1970);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('kokubun', 'tokio', 'tokyo', 'o',1974);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('matsuoka', 'tokio', 'hokkaido', 'a',1977);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('nagase', 'tokio', 'kanagawa', 'o',1978);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('ohno', 'arashi', 'tokyo', 'a',1980);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('sakurai', 'arashi', 'tokyo', 'a',1982);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('aiba', 'arashi', 'chiba', 'ab',1982);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('ninomiya', 'arashi', 'tokyo', 'a',1983);
// insert into Johnnys (name, team, bornIn, bloodType, birthYear) VALUES ('matsumoto', 'arashi', 'tokyo', 'a',1983);


}