#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>
#include <numeric>

typedef int64_t ll;
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, _s) for (int i = (_s);i < (int)( n ); i++)
#define all(_l) _l.begin(), _l.end()
#define rall(_l) _l.rbegin(), _l.rend()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &_l, const T b) {
    if (_l < b) {
        _l = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &_l, const T b) {
    if (_l > b) {
        _l = b;
        return true;
    }
    return false;
}

# ifdef LOCAL_DEBUG
template<typename T>
void vdeb(const std::vector<T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(const std::vector<std::vector<T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}
# endif

using namespace std;

void bfs(vector<vector<int>> &da, vector<int> &ans, vector<int> &c,int from) {
    int n = da.size();
    vector<int> used(n, -1);
    queue<Pii> q;
    q.push({from, 0});
    while(!q.empty()) {
        Pii now = q.front(); q.pop();
        if(used[now.first] != -1) {
            continue;
        }
        used[now.first] = now.second;
        rip(i,da[now.first].size(),0) {
            q.push({da[now.first][i], now.second+1});
        }
    }
    rip(i,c.size(),0) ans[i] = used[c[i]];
    return;
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> da(n, vector<int>(0));
    rip(i,m,0) {
        int a, b; cin >> a >> b;
        --a;--b;
        da[a].push_back(b);
        da[b].push_back(a);
    }
    int k; cin >> k;
    vector<int> c(k);
    rip(i,k,0) {
        cin>> c[i];
        c[i]--;
    }
    vector<vector<int>> dist(k, vector<int>(k, -1));
    rip(i, k, 0) bfs(da, dist[i], c, c[i]);
    rip(i,k,0) {
        rip(j,k,0) {
            if(dist[i][j] == -1) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    vector<vector<int>> dp(1<<k, vector<int>(k, INT_MAX/2));
    rip(i,k,0) {
        dp[1<<i][i] = 0;
    }
    rip(i,1<<k,0) {
        rip(j,k,0) {
            if((i>>j)&1) {
                rip(l,k,0) {
                    if((i>>l)&1) {
                        chmin(dp[i][j], dp[i^(1<<j)][l] + dist[l][j]);
                    }
                }
            }
        }
    }
    int ans = INT_MAX;
    rip(i,k,0) {
        chmin(ans, dp.back()[i]);
    }
    // vdeb(dp);
    cout << ans+1 << endl;
}
#include "bits/stdc++.h"
using namespace std; 

#ifdef LOCAL
    #include "debug.h"
    #define input freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
    #define debug(...) 4
    #define input 4
#endif

using ll = long long;
//const int mod = 998244353;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
struct DSU {
    int par[N];
    int sz[N];
    int find(int x) { 
        return x == par[x] ? x : par[x] = find(par[x]); 
    } //path compression(logn)
    
    void merge(int a, int b) {
        a = find(a);
        b = find(b);
        if(a == b) return;
        if(sz[a] < sz[b])
            swap(a, b);

        sz[a] += sz[b];
        par[b] = a;
    }

    void init(int n) {
        for(int i = 0; i <= n; i++)
            par[i] = i, sz[i] = 1;
    }
};
DSU d;
vector<int> g[N];
vector<int> dist[N];
int a[N];
void bfs(vector<int> &dist, int src) {
    queue<int> q;
    q.push(src);
    dist[src] = 0;
    while(q.size()) {
        int at = q.front();
        q.pop();
        for(int j : g[at]) {
            if(dist[j] == -1) {
                dist[j] = dist[at] + 1;
                q.push(j);
            }
        }
    }
}
int dp[1 << 18][18];
int k;
int solve(int mask, int last) {
    if(mask == (1 << k) - 1) {
        return 0;
    }
    if(~dp[mask][last])
        return dp[mask][last];
    int ans = 1e9;
    for(int j = 0; j < k; j++) {
        if(mask & (1 << j))
            continue;
        ans = min(ans, dist[last][a[j]] + solve(mask ^ (1 << j), j));
    }
    return dp[mask][last] = ans;
}
signed main() {
    input;
    cin.tie(nullptr) -> sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while(t--) {
        int n, m;
        cin >> n >> m;
        d.init(n + 1);
        for(int i = 0; i < m; i++) {
            int x, y;
            cin >> x >> y;
            g[x].push_back(y);
            g[y].push_back(x);
            d.merge(x, y);
        }
        cin >> k;
        set<int> s;
        for(int i = 0; i < k; i++) {
            cin >> a[i];
            s.insert(d.find(a[i]));
        }
        if(s.size() > 1) {
            cout << "-1\n";
            return 0;
        }
        for(int i = 0; i < k; i++) {
            vector<int> temp(n + 1, -1);
            bfs(temp, a[i]);
            dist[i] = temp;
        }
        int ans = 1e9;
        for(int i = 0; i < k; i++)  {
            memset(dp, -1, sizeof dp);
            ans = min(ans, solve(1 << i, i));
        }

        cout << ans + 1;

    }
}
