#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N, L;
    cin >> N >> L;
    vl A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    ll k = 0, ans = 0, last = 0;
    rep(i, N){      // 右に走査
        if (i < last) A[i] = A[last] - (last - i);
        if (A[i] >= B[i] or B[i] == i + 1 or B[i] == L - (N - i - 1)) continue;
        chmax(k, i + 1);

        while (k < N and B[i] != A[k] - (k - i)) k++;
        if(k == N){
            cout << -1 << endl;
            return 0;
        }

        ans += k - i, last = k;
        A[i] = B[i];
    }

    k = N, last = N;
    repr(i, N){     // 左に走査
        if (i > last) A[i] = A[last] + (i - last);
        if (A[i] <= B[i] or B[i] == i + 1 or B[i] == L - (N - i - 1)) continue;
        chmin(k, i - 1);

        while (k >= 0 and B[i] != A[k] + (i - k)) k--;
        if(k == -1){
            cout << -1 << endl;
            return 0;
        }

        ans += i - k, last = k;
        A[i] = B[i];
    }

    rep(i, N){      // 端点
        if (A[i] == B[i]) continue;
        ans++;
    }

    cout << ans << endl;
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
constexpr int INF = 1e9, MOD = 1e9 + 7;
constexpr int64_t LINF = 5e18, LMOD = 998244353;
// #include <atcoder/all>
// using namespace atcoder;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int n, m;
int k;
int c[18];
vector<int> edge[100010];
int64_t dist[18][100010];

void f() {
	rep(i,k)rep(j,n) {
		dist[i][j] = INF;
	}
	for(int i = 0; i < k; ++i) {
		queue<int> que;
		dist[i][c[i]] = 0;
		que.push(c[i]);
		while(not que.empty()) {
			int from = que.front();
			que.pop();
			for(int to : edge[from]) {
				if(dist[i][from] + 1 >= dist[i][to]) continue;
				que.push(to);
				dist[i][to] = dist[i][from] + 1;
			}
		}
	}
}

int64_t dp[1 << 18][18];
int main() {
	cin >> n >> m;
	rep(i,m) {
		int a, b; cin >> a >> b;
		--a, --b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	cin >> k;
	rep(i,k) {
		cin >> c[i];
		--c[i];
	}
	f();
	rep(i,(1<<k))rep(j,k) dp[i][j] = INF;
	rep(i,k) {
		dp[1 << i][i] = 1;
	}
	for(int mask = 1; mask < (1 << k); ++mask) {
		for(int i = 0; i < k; ++i) {
			if(mask >> i & 1) {
				rep(j,k) {
					if(dist[i][c[j]] == INF) continue;
					dp[mask | (1 << j)][j] = min(dp[mask | (1 << j)][j], dp[mask][i] + dist[i][c[j]]);
				}
			}
		}
	}

	int64_t ans = INF;
	int ma = (1 << k) - 1;
	rep(i,k) {
		ans = min(ans, dp[ma][i]);
	}
	if(ans == INF) {
		cout << -1 << '\n';
	} else {
		cout << ans << '\n';
	}
	return 0;
}
