//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, M, K;
int to[200001], ne[200001], he[100001];
int D[100001], C[20], Q[100001], q;
int DD[20][20];
int dp[1 << 17][17];

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	N = getint();
	M = getint() * 2;
	rep1(i, M) {
		int a = getint(), b = getint();
		to[i] = b;
		ne[i] = he[a];
		he[a] = i++;
		to[i] = a;
		ne[i] = he[b];
		he[b] = i;
	}
	K = getint();
	rep(i, K) C[i] = getint();

	if (K == 1) {
		printf("1");
		return 0;
	}
	
	const int dekai = 1e8, choidekai = 5e6;
	for (int p = 1; p < K; p++) D[C[p]] = dekai + p;

	rep(k, K - 1) {

		int b = -choidekai * k;
		D[C[k]] = b - choidekai;

		int mada = 0;
		for (int i = K - 1; i > k; i--) mada |= (1 << i);
		int p = 0;
		q = 0;
		Q[q++] = C[k];
		while (mada && p < q) {
			int i = Q[p++];
			int d = D[i] + 1;
			for (int t = he[i]; t; t = ne[t]) {
				int T = to[t];
				if (D[T] >= b) {
					if (D[T] >= dekai) mada ^= 1 << (D[T] - dekai);
					D[T] = d;
					Q[q++] = T;
				}
			}
		}
		rep(p, K) {
			if (p > k) {
				DD[k][p] = D[C[p]] - b + choidekai;
				DD[p][k] = D[C[p]] - b + choidekai;
			}
			if (p > k + 1) D[C[p]] = dekai + p;
		}
	}
	rep(i, K) dp[1 << i][i] = 1 - choidekai;


	rep1(b, (1 << K) - 1) {
		int X[17], Y[17];
		auto x = X, y = Y;
		rep(i, K) {
			if (b >> i & 1) *x++ = i;
			else *y++ = i;
		}
		auto dp0 = dp[b];
		for (auto j = Y; j < y; j++) {
			int saishou = 0;
			for (auto i = X; i < x; i++) {
				if (saishou > dp0[*i] + DD[*j][*i]) saishou = dp0[*i] + DD[*j][*i];
			}
			dp[1 << *j | b][*j] = saishou;
		}
	}

	int kotae = 0;
	rep(i, K) chmin(kotae, dp[(1 << K) - 1][i]);

	if (kotae < 0) printf("%d", kotae + choidekai);
	else printf("-1");

	Would you please return 0;
}
#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)
inline void RI(i64 &i) {scanf("%lld", &(i));}
inline void RVI(vi &v) { for(i64 i=0;i<sz(v);++i) { RI(v[i]); } }
inline void RVVI(vvi &vv) { for(i64 i=0;i<sz(vv);++i) { RVI(vv[i]); } }
inline void WI(const i64 &i) {printf("%lld\n", i);}
inline void WVI(const vi &v, char sep=' ') { for(i64 i=0;i<sz(v);++i) { if(i != 0){ printf("%c", sep); } printf("%lld", v[i]);} printf("\n"); }
inline void WS(const string &s) { printf("%s\n", s.c_str()); }
inline void WB(bool b, const string &yes, const string &no) { if(b){ WS(yes);} else { WS(no);} }
inline void YESNO(bool b) { WB(b, "YES", "NO"); }
#define BUF_LENGTH 1000000
inline void RS(string &s) {static char buf[BUF_LENGTH]; scanf("%s", buf); s = buf;}
template<typename T> inline bool IN(T &S, const typename T::key_type &key) {
  return S.find(key) != S.end();
}

int main(int argc, char *argv[]) {
  i64 i, j, k; 
  i64 N, M;
  cin >> N >> M;
  vvi E0(N);
  REP(0, M, i) {
    i64 a, b;
    RI(a); RI(b);
    a--; b--;
    E0[a].pb(b);
    E0[b].pb(a);
  }

  i64 K;
  cin >> K;
  vi C(K); RVI(C);
  vi dists0(N, -1);
  vvi dists(K, vi(K, -1));
  REP(0, K, i) {
    C[i]--;
  }

  if(K == 1) {
    cout << 1 << endl;
    return 0;
  }

  REP(0, K, i) {
    fill(all(dists0), -1);
    queue<i64> q;
    dists0[C[i]] = 0;
    q.push(C[i]);
    while(!q.empty()) {
      i64 cur = q.front();
      q.pop();
      for(auto next: E0[cur]) {
        if(dists0[next] == -1) {
          dists0[next] = dists0[cur] + 1;
          q.push(next);
        }
      }
    }
    REP(0, K, j) {
      dists[i][j] = dists0[C[j]];
    }
  }

  /*
  REP(0, K, i) {
    REP(0, K, j) {
      assert(dists[i][j] == dists[j][i]);
    }
  }
  */

  i64 B = 1 << K;
  vvi ans(B, vi(K, -1));
  fill(all(ans[0]), 0);
  using ppi = pair<i64, pi>; // dist, {b, k}
  set<ppi> q;
  REP(0, K, i) {
    q.insert({0, {1<<i, i}});
  }

  while(!q.empty()) {
    auto t = *q.begin();
    q.erase(q.begin());
    i64 d = t.first, b = t.second.first, i = t.second.second;
    REP(0, K, j) {
      if(i != j && dists[i][j] != -1) {
        i64 bn = b | (1 << j);
        if(bn == b) {
          continue;
        }
        i64 dn = d + dists[i][j];
        if(ans[bn][j] == -1 || dn < ans[bn][j]) {
          auto it = q.find({ans[bn][j], {bn, j}});
          assert(ans[bn][j] == -1 || it != q.end());
          if(it != q.end()) {
            q.erase(it);
          }
          ans[bn][j] = dn;
          q.insert({ans[bn][j], {bn, j}});
        }
      }
    }
  }

  i64 res = -1;
  REP(0, K, i) {
    if(ans.back()[i] != -1) {
      if(res == -1) {
        res = ans.back()[i] + 1;
      }
      else {
        res = min(res, ans.back()[i] + 1);
      }
    }
  }
  printf("%lld\n", res);

  return 0;
}

