#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;

    }
}

#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18+7;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T> 
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*
方針


*/
ll n,m;
vector<ll>a,b;
ll k;
vector<ll>c;

Graph g;

vector<ll>dist;

ll kyori[20][20];


int main(){
	cin >> n >> m;
	a.resize(m);
	b.resize(m);
	g.resize(n);
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	cin >> k;
	c.resize(k);
	rep(i,k){
		cin>>c[i];
		c[i]--;
	}

    ll start,goal;

	rep(i,20)rep(j,20)kyori[i][j]=INF;
	rep(i,k){
		vector<ll>dist(n,INF);
		queue<ll>que;
		que.push(c[i]);
		dist[c[i]]=0;
		while(!que.empty()){
			auto v = que.front();que.pop();
			for(auto x:g[v]){
				if(dist[x]!=INF)continue;
				dist[x]=dist[v]+1;
				que.push(x);
			}
		}
        ll M = 0;
		rep(j,k){
			if(dist[c[j]]==INF){
				cout << -1 << endl;
				return 0;
			}
			kyori[i][j]=dist[c[j]];
            if(chmax(M,kyori[i][j])&&i==0){
                goal = j;
            }
            if(chmax(M,kyori[i][j])&&i==goal){
                start = j;
            }
		}
	}	


	//bitDP
	ll ans = INF;
	rep(test,12){
        ll i = (start+test)%k;
		vector<vector<ll> >dp(((1<<k)+1),vector<ll>(k+1,INF));
        dp[(1<<i)][i]=1;
		rep(S,(1<<k)){
			rep(v,k){
				rep(u,k){
					if (S != 0 && !(S & (1 << u))) continue; // u を含まない場合を除く
					if ((S & (1 << v)) == 0) {
						if (v != u) chmin(dp[S | (1 << v)][v], dp[S][u] + kyori[u][v]);
					}
				}
			}
		}
		rep(j,k){
			chmin(ans,dp[(1<<k)-1][j]);
		}

	}
    /*
    rep(test,5){
        ll i = (goal+test*2)%k;
		vector<vector<ll> >dp(((1<<k)+1),vector<ll>(k+1,INF));
        dp[(1<<i)][i]=1;
		rep(S,(1<<k)){
			rep(v,k){
				rep(u,k){
					if (S != 0 && !(S & (1 << u))) continue; // u を含まない場合を除く
					if ((S & (1 << v)) == 0) {
						if (v != u) chmin(dp[S | (1 << v)][v], dp[S][u] + kyori[u][v]);
					}
				}
			}
		}
		rep(j,k){
			chmin(ans,dp[(1<<k)-1][j]);
		}

	}
    */
	cout << ans << endl;
	return 0;

}