#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli a,b;cin>>a>>b;
    lli sum=0;
    flli(i,1,a)
    {
    	lli var=500500+i;
    	cout<<var<<" ";
    	sum+=var;
    }
    flli(i,1,b-1)
    {
    	cout<<-i<<" ";
    	sum-=i;
    }
    cout<<-sum;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll n, m;
    cin >> n >> m;
    ll a, b;
    vvll g(n);
    REP(i, m) {
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll k;
    cin >> k;
    vll c(k);
    REP(j, k) {
        cin >> c[j];
        c[j]--;
    }
    auto BFS = [&](int s){
        vll cost(n, INF);
        cost[s] = 0;
        queue<int> q;
        q.push(s);
        while(q.size()){
            int x = q.front();
            q.pop();
            for(int y : g[x]) if(chmin(cost[y], cost[x] + 1)) q.push(y);
        }
        for(int i = 0; i < k; i++) cost[i] = cost[c[i]];
        cost.resize(k);
        return cost;
    };
    
    vvll d(k);
    REP(i, k) d[i] = BFS(c[i]);

    vvll dp(k, vll(1 << k, INF));
    REP(i, k) dp[i][0] = 0;
    for(int bit = 1; bit < (1 << k); bit++){
        REP(j, k) if(bit >> j & 1) {
            REP(x, k){
                ll cost = dp[j][bit - (1 << j)] + d[j][x];
                if (bit == ((1 << k) - 1)) chmin(dp[x][bit], dp[j][bit - (1 << j)]);
                chmin(dp[x][bit], cost);
            }
        }
    }

    ll ans = INF;
    REP(i, k) chmin(ans, dp[i][(1 << k) - 1]);

    if(ans == INF) ans = -2;
    cout << ans + 1 << endl;
    return 0;
}