
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define debug(...) fprintf(stderr, __VA_ARGS__);
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 Rand(seed);
uniform_int_distribution<ll> ran(0, 1ll << 62);
void ucin() {
  ios::sync_with_stdio(0); cin.tie(0);
}
// uniform_real_distribution<double> dbran;
template<class T> inline void chkmax(T &x, const T &y) { if(x < y) x = y; }
template<class T> inline void chkmin(T &x, const T &y) { if(x > y) x = y; }

inline ll sqr(ll x) { return x * x; }
inline ll cub(ll x) { return x * x * x; }
const ll INF = 1ll << 60;
int n, m, d[18][N];
ll ans;
vector<int> G[N];
void getdis(int s, int *d) {
  fill(d + 1, d + n + 1, -1);
  queue<int> q; d[s] = 0; q.push(s);
  while(q.size()) {
    int u = q.front(); q.pop();
    for(int v : G[u]) if(-1 == d[v]) {
      d[v] = d[u] + 1; q.push(v);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  rep(i, 1, m) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].pb(v); G[v].pb(u);
  }
  static int seq[32];
  static ll dp[1 << 17 | 5][19];
  int k; scanf("%d", &k);
  rep(i, 1, k) scanf("%d", seq + i);
  rep(i, 1, k) getdis(seq[i], d[i]);
  for(int i = 0; i < k; i ++) dp[1 << i][i] = 0;
  for(int i = 1; i < (1 << k); i ++) {
    int c = 0;
    for(int j = 0; j < k; j ++) c += i >> j & 1;
    if(c == 1) continue ;
    for(int j = 0; j < k; j ++) if(i >> j & 1) {
      dp[i][j] = INF;
      for(int u = 0; u < k; u ++) if(u != j && (i >> u & 1) && dp[i ^ (1 << j)][u] < INF && ~d[u + 1][seq[j + 1]]) {
        chkmin(dp[i][j], dp[i ^ (1 << j)][u] + d[u + 1][seq[j + 1]]);
      }
    }
  }
  ll ans = INF;
  for(int i = 0; i < k; i ++) chkmin(ans, dp[(1 << k) - 1][i]);
  cout << ( ans == INF ? -1 : 1 + ans ) << '\n';
  return 0;
}
#include <bits/stdc++.h>
#define all(x)    x.begin(), x.end()
#define allr(x)   x.rbegin(), x.rend()
#define sz(x)     ((int)x.size())
#define ln(x)     ((int)x.length())
#define mp        make_pair
#define pb        push_back
#define ff        first
#define ss        second
#define endl      '\n'
#define dbg(x)    cout << #x << ": " << x << endl;
#define clr(x,v)  memset(x, v, sizeof(x));
#define fix(x)    cout << setprecision(x) << fixed;
#define FASTIO    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

using ll = long long int;
using ld = long double;
using pi = pair<int, int>;

const double PI = acos(-1.0);
const double eps = 1e-9;
const ll mod = 1e9 + 7;
const int inf = 1e7;
const int MAXN = 1e5 + 5;

int dp[17][1 << 17];

void cp()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for(int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int k;
    cin >> k;
    vector<int> gem(k);
    for(int &x : gem)
        cin >> x, x--;

    bool ok = true;

    vector<vector<int>> dist(k, vector<int>(k, inf));
    for(int i = 0; i < k; i++)
    {
        vector<bool> vis(n);
        vector<int> D(n, inf);
        queue<int> q;
        q.push(gem[i]);
        D[gem[i]] = 0;
        while(!q.empty())
        {
            int u = q.front();
            q.pop();
            vis[u] = 1;

            for(int v : adj[u])
                if(!vis[v])
                    q.push(v), D[v] = D[u] + 1, vis[v] = 1;
        }

        for(int j = 0; j < k; j++)
            dist[i][j] = D[gem[j]];
    }

    function<int(int, int)> solve = [&](int i, int mask)
    {
        if(mask == (1 << k) - 1) return 0;
        int &ret = dp[i][mask];
        if(~ret) return ret;
        int ans = inf;
        for(int j = 0; j < k; j++)
            if(!((mask >> j) & 1))
                ans = min(ans, dist[i][j] + solve(j, mask | (1 << j)));
        return ret = ans;
    };
    clr(dp, -1);
    int ans = inf;
    for(int i = 0; i < k; i++)
        ans = min(ans, 1 + solve(i, 1 << i));

    if(ans == inf) ans = -1;
    cout << ans << endl;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

