#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<int,int> pi;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 200005;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
class BIT{
    private:
        vector<ll> bit;
        ll size;
    public:
        BIT(ll n){
            bit.resize(n+1);
            size = n;
        }
        ll sum(ll i){
            ll res = 0;
            while(i > 0){
                res += bit[i];
                i -= i&-i;
            }
            return res;
        }
        void add(ll i,ll x){
            while(i <= size){
                bit[i] += x;
                i += i&-i;
            }
        }
};

int main(){
    ll h,w,m;
    cin >> h >> w >> m;
    vector<vector<ll>> x(h);
    vector<ll> y(w,h);
    ll ox = h,oy = w;
    rep(i,m){
        ll s,t;
        cin >> s >> t;
        s--,t--;
        x[s].push_back(t);
        chmin(y[t],s);
        if (s == 0) chmin(oy,t);
        if (t == 0) chmin(ox,s);
    }
    rep(i,h){
        x[i].push_back(w);
        SORT(x[i]);
    }
    ll ans = 0;
    BIT a(w+1);
    rep(i,ox){
        if (i == 0){
            rep(j,x[i][0]+1,w+1){
                a.add(j,1);
            }
        }
        else{
            for (ll ind:x[i]){
                if (a.sum(ind+1)-a.sum(ind) == 0){
                    a.add(ind+1,1);
                }
            }
        }
        ans += x[i][0]-(x[i][0]-a.sum(x[i][0]));
        //PRINT(x[i][0] << " " << a.sum(x[i][0]));
    }
    rep(i,oy){
        ans += y[i];
    }
    PRINT(ans);
}

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int k;
    cin >> k;
    vector<ll> c(k);
    set<int> p;
    rep(i, k) {
        cin >> c[i];
        c[i]--;
        p.insert(c[i]);
    }

    vector<vector<ll>> dist(k, vector<ll>(k));
    queue<ll> q;

    rep(i, k) {
        q.push(c[i]);
        vector<ll> tmp_dist(n, INF);
        tmp_dist[c[i]] = 0;
        while (!q.empty()) {
            ll crr = q.front();
            q.pop();
            for (auto next : G[crr]) {
                if (tmp_dist[crr] + 1 < tmp_dist[next]) {
                    tmp_dist[next] = tmp_dist[crr] + 1;
                    q.push(next);
                }
            }
        }
        rep(j, k) dist[i][j] = tmp_dist[c[j]];
    }

    // bitdp
    ll max_s = 1 << k;
    vector<vector<ll>> dp(max_s, vector<ll>(k, INF));
    rep(i, k) dp[1 << i][i] = 1;
    reps(bit, max_s, 1) {
        rep(i, k) {
            if ((bit >> i) & 1) {
                ll target_bit = 1 << i;
                ll bit2 = bit ^ target_bit;
                rep(j, k) {
                    if ((bit2 >> j) & 1) { dp[bit][i] = min(dp[bit][i], dp[bit2][j] + dist[i][j]); }
                }
            }
        }
    }
    ll res = INF;
    for (ll val : dp[max_s - 1]) res = min(res, val);
    if (res == INF) res = -1;
    cout << res << endl;
    return 0;
}