#include<bits/stdc++.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    //input part
    //0 index
    int N,M; cin>>N>>M;
    Graph G(N);
    rep(i,M){
        int a,b; cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    int K; cin>>K;
    vector<int> C(K);
    rep(i,K){
        cin>>C[i];
        C[i]--;
    }
    //BFS part
    auto BFS = [&](int s){
        vector<ll> dist(N,INF);
        dist[s] = 0;
        queue<int> Q;
        Q.push(s);
        while(!Q.empty()){
            int now = Q.front();
            Q.pop();
            for(auto next: G[now]){
                if(dist[next]!=INF)continue;
                dist[next] = dist[now]+1;
                Q.push(next);
            }
        }
        vector<ll> res(K,INF);
        rep(i,K)res[i] = dist[C[i]];
        return res;
    };
    //bit dp part
    vector<vector<ll>> dist(K);
    rep(i,K) dist[i] = BFS(C[i]);

    vector<vector<ll>> dp(1<<K, vector<ll> (K,INF));
        //init
    rep(i,K)dp[1<<i][i] = 1;
    for(int bit = 0; bit < (1<<K); bit++){
        rep(i,K){
            if(bit & 1<<i){
                int bit2 = bit ^ 1<<i;
                rep(j,K){
                    if(bit2 & 1<<j){
                        dp[bit][i] = min(dp[bit][i],dp[bit2][j]+dist[i][j]);
                    }
                }
            }
        }
    }
    ll res = *min_element(dp.back().begin(),dp.back().end());
    if(res>=INF) res =  -1;
    cout<<res<<endl;
}

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include<iomanip>

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using pll = std::pair<ll, ll>;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vb = std::vector<bool>;
using db = double;
using vdb = std::vector<db>;
using qlg= std::priority_queue<ll, vl, std::greater<ll> > ; //ascending
using qll= std::priority_queue<ll, vl, std::less<ll> > ; // descending
using qdg= std::priority_queue<db, vdb, std::greater<db> > ; //ascending
using qdl= std::priority_queue<db, vdb, std::less<db> > ; // descending
template<class T>
using vv = std::vector<std::vector<T> >;


#define REPL(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FORL(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FORL(i, 0, n)

#define MREP(i, n) for (ll i= (ll)(n)-1; i>=0; i-- )
#define MFOR(i, a, b) for (ll i = (ll)(b)-1; i >= (ll)(a); i--)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
#define INF pow(10, 10)

void do_swap(vl &swaps, ll &Times, vector<bool> &Is_swaped, ll pos, vl &diffs, queue<ll> &Plus)
{
    swaps[Times ++] = pos+1;
    Is_swaped[pos] = true;
    swap(diffs[pos], diffs[pos+1]);

    diffs[pos] ++;
    diffs[pos+1] --;
    if(diffs[pos+1] > 0) Plus.push(pos+1);
}

int main(void)
{

    ll Sc, P, N, M, Q, A, B, C, D, K;

    cin >> N;
    queue<ll> Plus;
    vl diffs(N);
    bool resres = true;
    REP(i, N)
    {
        cin >> diffs[i];
        diffs[i] = diffs[i]-i-1;
        if(diffs[i] > 0)
        {
            Plus.push(i);
        }
        else if(diffs[i]==0)
        {
            resres = false;
        }
    }

    if(resres==false)
    {
        cout << -1 << endl;
        return 0;
    }

    REP(i, N-1)
    {
        if(diffs[i]>0 && diffs[i+1] >0 && diffs[i] > diffs[i+1])
        {
            cout << -1 << endl;
            return 0;
        }
        else if(diffs[i]<0 && diffs[i+1] <0 && diffs[i] > diffs[i+1])
        {
            cout << -1 << endl;
            return 0;
        }
    }

    vl swaps(N);
    ll Times = 0;
    vector<bool> Is_swaped(N-1, false);
    vl Move_Afts(N, -1);

    bool res_moved = true;



    while(!Plus.empty() )
    {
        ll pos;

        pos = Plus.front(); Plus.pop();


        if(Is_swaped[pos] == true || diffs[pos+1]==0)
        {
            break;
        }
        else if(diffs[pos+1]<0)
        {
            do_swap(swaps, Times, Is_swaped, pos, diffs, Plus);
            /*
            swaps[Times ++] = pos+1;
            Is_swaped[pos] = true;
            swap(diffs[pos], diffs[pos+1]);

            diffs[pos] ++;
            diffs[pos+1] --;
            if(diffs[pos+1] > 0) Plus.push(pos+1);
            */

            ll aft = Move_Afts[pos];
            while(aft >= 0 && diffs[aft+1]<0)
            {
                do_swap(swaps, Times, Is_swaped, aft, diffs, Plus);
                aft = Move_Afts[aft];
            }
        }
        else
        {
            Move_Afts[pos+1] = pos;
        }


    }

    if(Times == N-1)
    {
        // cout << Times << "  ";
        REP(i, Times)
        {
            cout << swaps[i] << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }


    return 0;
}
