// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const long double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


class DIJ{
	public:
	struct edge{
		Def to,cost;
	};
	vector<vector<edge> >G;
	Def n;
	vi d;//distance
	DIJ(Def size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(Def a,Def b,Def c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	vi dij(Def s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			Def pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				Def to=e.to;
				Def nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
		return d;
	}
};

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin>>n>>m;
	DIJ dij(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		dij.add_edge(a,b,1);
	}
	int k;
	cin>>k;
	vi in(k);
	rep(i,k)cin>>in[i],in[i]--;
	vvi G(k);
	rep(i,k)G[i]=dij.dij(in[i]);

	vvi dp(1<<k,vi(k,inf));
	rep(i,k)dp[1<<i][i]=1;
	rep(i,1<<k)rep(j,k)if(dp[i][j]+inf)rep(l,k)if(!(i&1<<l)){
		cmin(dp[i|1<<l][l],dp[i][j]+G[j][in[l]]);
	}
	int out=inf;
	rep(i,k)cmin(out,dp.back()[i]);
	if(out==inf)out=-1;
	cout<<out<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353
#define N 400005
#define l(x) (x&(-x)) 
int n,a[N],b[N],c[N]; 
vector<int>to[N];
struct lsh{
	int pos,val;
}a_[N<<1],b_[N];
inline void add(int x){while(x<N)++c[x],x+=l(x);}
inline int sum(int x){int ret=0;while(x)ret+=c[x],x-=l(x);return ret;}
inline bool cmp(lsh aa,lsh bb){
	return aa.val<bb.val;
}
int i,cnt;
long long ans;
int main(){
	cin>>n;
	for(i=1;i<=n;++i)cin>>a[i],a[i]+=i,a_[i].val=a[i],a_[i].pos=i;
	for(i=1;i<=n;++i)cin>>b[i],b[i]+=i,a_[i+n].val=b[i],a_[i+n].pos=i+n;
	sort(a_+1,a_+n+n+1,cmp);
	for(i=1;i<=n+n;++i){
		if(a_[i].val!=a_[i-1].val)++cnt;
		if(a_[i].pos>n)b[a_[i].pos-n]=cnt;
		else a[a_[i].pos]=cnt;
	}
	for(i=1;i<=n;++i)++c[a[i]],--c[b[i]];
	//,cout<<a[i]<<" "<<b[i]<<"\n";
	for(i=1;i<=n+n;++i){
		if(c[i])return cout<<"-1",0;
	}
	for(i=1;i<=n;++i)to[a[i]].push_back(i);
	for(i=1;i<=n;++i){
		++c[b[i]];
		b[i]=to[b[i]][c[b[i]]-1];
	}
	memset(c,0,sizeof(c));
	for(i=1;i<=n;++i){
		ans+=sum(b[i]);
		add(b[i]);
	}
	cout<<1ll*n*(n-1)/2-ans;
}