#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <stack>

using namespace std;

vector<int> G[100000];
const int INF = 0x3f3f3f3f;
int N, M, K;
int arr[18];
int dist[18][100000];
int dp[18][1 << 18];

void bfs(int src) {
    for (int i = 0; i < N; i++) {
        dist[src][i] = INF;
    }
    queue<int> q;
    dist[src][arr[src]] = 0;
    q.push(arr[src]);

    while (!q.empty()) {
        int curr = q.front();
        q.pop();

        for (auto &g : G[curr]) {
            if (dist[src][g] == INF) {
                dist[src][g] = dist[src][curr] + 1;
                q.push(g);
            }
        }
    }
}

int solve(int start, int mask) {
    if (mask == (1 << K) - 1) return 0;
    int &ret = dp[start][mask];
    if (ret != -1) return ret;

    ret = INF;
    for (int i = 0; i < K; i++) {
        if (mask & (1 << i)) continue;
        ret = min(ret, solve(i, mask | (1 << i)) + dist[i][arr[start]]);
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof(dp));
    cin >> N >> M;
    for (int i = 0, u, v; i < M; i++) {
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    cin >> K;
    for (int i = 0; i < K; i++) {
        cin >> arr[i];
        arr[i]--;
    }

    for (int i = 0; i < K; i++)
        bfs(i);
    for (int i = 0; i < K; i++) {
        if (dist[i][arr[0]] == INF) {
            cout << -1 << '\n';
            return 0;
        }
    }

    int ans = INF;
    for (int i = 0; i < K; i++)
        ans = min(ans, 1 + solve(i, (1 << i)));
    cout << ans << '\n';
    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const ll inf=0x3f3f3f3f3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0',  ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} };

bool vis[maxn];
vector<vector<ll> > D(maxn);
ll dis[20][20];
ll d[maxn];

void bfs(int s)
{
    queue<PII> q;
    q.push(mp(s,0));
    vis[s] = 1;
    while(!q.empty())
    {
        ll x = q.front().fi;
        ll dd = q.front().se;
        q.pop();
        d[x] = dd;
        for(int i=0; i<D[x].size(); i++)
        {
            ll y = D[x][i];
            if(!vis[y])
            q.push(mp(y,dd+1)), vis[y] = 1;
        }
    }
}

ll a[maxn];
ll dp[1<<18][20];

int main()
{
    ll n = read(), m = read();
    rep(i,1,m)
    {
        ll x = read(), y = read();
        D[x].pb(y);
        D[y].pb(x);
    }
    ll k = read();
    rep(i,1,k) a[i] = read();
    ll ans = inf;
    rep(i,1,k)
    {
        rep(j,1,n) vis[j] = 0, d[j] = inf;;
        bfs(a[i]);
        rep(j,1,k) dis[i][j] = d[a[j]];
    } //cout<<"wa"<<endl;
    mem(dp,inf);
    rep(i,0,k-1) dp[1<<i][i+1] = 1;

    rep(i,1,(1<<k)-1)
    {
        rep(j,1,k)
        {
            if(dp[i][j]==inf) continue;
            rep(nextOne,1,k)
            {
                if(nextOne==j) continue;
                if(!(i>>(nextOne-1)&1))
                {
                    int nextState = i + (1<<(nextOne-1)) ;
                    //cout<<dis[j][head]<<' '<<i<<' '<<j<<' '<<head<<endl;
                    dp[nextState][nextOne] = min(dp[nextState][nextOne], dp[i][j] + dis[j][nextOne]);
                }
            }

        }
    }
    rep(i,1,k) ans = min(ans,dp[(1<<k)-1][i]);
    if(ans==inf) cout<<-1<<endl;
    else
    cout<<ans<<endl;
    return 0;
}
