#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
template <typename T>
void read(T &x) {
	T flag = 1;
	char ch = getchar();
	for (; '0' > ch || ch > '9'; ch = getchar())
		if (ch == '-')
			flag = -1;
	for (x = 0; '0' <= ch && ch <= '9'; ch = getchar())
		x = x * 10 + ch - '0';
	x *= flag;
}
struct node{
	ll pre, to;
}edge[MAXN << 1];
ll head[MAXN], tot;
ll n, m, k;
ll c[20];
ll dis[20][100005];
ll dp[1 << 18][18];
bool vis[100005];
void add_edge(ll u, ll v) {
	edge[++tot] = node{head[u], v};
	head[u] = tot;
}
priority_queue<pair<int, int> > q;
void dijkstra(ll s) {
	memset(vis, 0, sizeof(vis));
	memset(dis[s], 0x3f, sizeof(dis[s]));
	dis[s][c[s]] = 0;
	q.push(make_pair(0, c[s]));
	while (!q.empty()) {
		ll x = q.top().second;
		q.pop();
		if (vis[x]) continue;
		vis[x] = true;
		for (ll i = head[x]; i; i = edge[i].pre) {
			ll y = edge[i].to;
			if (dis[s][y] > dis[s][x] + 1) {
				dis[s][y] = dis[s][x] + 1;
				q.push(make_pair(-dis[s][y], y));
			}
		}
	}
}
int main() {
	read(n); read(m);
	for (ll i = 1; i <= m; i++) {
		ll a, b;
		read(a); read(b);
		add_edge(a, b);
		add_edge(b, a);
	}
	read(k);
	for (ll i = 1; i <= k; i++) read(c[i]), dijkstra(i);
	memset(dp, 0x3f, sizeof(dp));
	ll ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i <= k; i++) dp[1 << (i - 1)][i] = 1;
	for (ll i = 1; i < (1 << k); i++) {
		for (ll j = 1; j <= k; j++) {
			if ((i >> (j - 1)) & 1) {
				for (ll l = 1; l <= k; l++) {
					if ((i >> (l - 1)) & 1) continue;
					dp[i | (1 << (l - 1))][l] = min(dp[i | (1 << (l - 1))][l], dp[i][j] + dis[j][c[l]]);
				}
			}
		}
	}
	ll goal = (1 << k) - 1;
	for (ll i = 1; i <= k; i++) {
		ans = min(ans, dp[goal][i]);
	}
	if (ans >= 0x3f3f3f3f3f3f3f3f) puts("-1");
	else printf("%lld\n", ans);
	return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

using ll = long long;
using P = pair<int, int>;
using vvi = vector<vector<int>>;
using vi = vector<int>;

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const double PI = 3.14159265358979323846;


void solve() {
    int n, m, k;
    cin >> n >> m;
    vvi G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cin >> k;
    vector<int> C(k);
    rep(i, k) {
        int c;
        cin >> c;
        c--;
        C[i] = c;
    }

    vvi cost(k);
    auto bfs = [&](int start) {
        vector<int> mindist(n, INF);
        queue<P> q;
        q.push(make_pair(start, 0));
        mindist[start] = 0;
        while (!q.empty()) {
            auto now = q.front(); q.pop();
            for (auto next : G[now.first]) {
                int nd = now.second + 1;
                if (mindist[next] <= nd) continue;
                mindist[next] = nd;
                q.push(make_pair(next, nd));
            }
        }
        vector<int> res(k);
        rep(i, k) res[i] = mindist[C[i]];
        return res;
    };

    rep(i, k) cost[i] = bfs(C[i]);

    vector<vector<ll>> dp(1<<k, vector<ll>(k, INF));
    rep(i, k) dp[1<<i][i] = 1;
    
    for (int x = 0; x < (1<<k); x++) {
        rep(to, k) {
            rep(from, k) {
                if (x != 0 && !(x & (1<<from))) continue;
                if ((x & (1<<to)) == 0) {
                    if (to != from) {
                        chmin(dp[x|(1<<to)][to], dp[x][from] + cost[from][to]);
                    }
                }
            }
        }
    }
    ll ans = INF;
    rep(i, k) chmin(ans, dp[(1<<k)-1][i]);
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

int main() {

    solve();

    return 0;
}
