#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define rep(i,n) for (ll i = 0;i<(n);++i)
#define all(v) v.begin(),v.end()

template <typename T>bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false;}
template <typename T>bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false;}
vector<long long> divisor(long long n){vector<long long> res;long long i = 1;while (i*i<=n){if(n%i==0){res.push_back(i);}i++;}if(res.size()==0)return res;for(long long i = res.size()-1-(res.back()*res.back()==n);i>=0;--i){res.push_back(n/res[i]);}return res;}
long long safe_mod(long long x,long long m){x%=m;if(x<0){x+=m;}return x;}
long long modpow(long long x,long long n,long long mod){long long ans=1;while(n>0){if(n&1){ans*=x;ans%=mod;}n>>=1;x*=x;x%=mod;}return ans;}
long long intpow(long long x,long long n){long long ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
vector<pair<long long,long long>> factor_lst(long long n){vector<pair<long long,long long>> factor_lst;long long d=2;while(d*d<=n){if(n%d==0){long long num=0;while(n%d==0){num+=1;n/=d;}factor_lst.push_back({d,num});}d+=1;}if(n!=1){factor_lst.push_back({n,1});}return factor_lst;}

int msb(int x){return x==0 ? -1:32-__builtin_clz(x);}//1-indexed
int lsb(int x){return x==0 ? 32:__builtin_ctz(x)+1;}//1-indexed
int popcnt(int x){return __builtin_popcount(x);}

const ll LINF=4*1e18;
const ll MINF=5*1e15;
const int INF=2*1e9;
template<class T>
class Queue{
    struct node{
        T val;
        node *next,*prev;
    };
    node *head=NULL,*tail=NULL;
    public:
        bool empty(){return head==NULL;}
        void push(T v){
            node *q=new node;
            q->val=v;
            q->prev=tail;
            q->next=NULL;
            if(tail!=NULL)tail->next=q;
            tail=q;
            if(head==NULL)head=q;
        }
        T pop(){
            node *q=head;
            head=q->next;
            if(head!=NULL)head->prev=NULL;
            T v=q->val;
            delete q;
            if(head==NULL)tail=NULL;
            return v;
        }
        T front(){
            return head->val;
        }

        
};

void Main();
int main(){cout<<fixed<<setprecision(15);Main();}

void Main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>> G(N);
  rep(i,M){
      int A,B;
      cin>>A>>B;
      A--;B--;
      G[A].push_back(B);
      G[B].push_back(A);
  }
  int K;
  cin>>K;
  int C[K];
  rep(i,K){
      cin>>C[i];
  C[i]--;
  }
  int table[K][K];
  rep(s,K){
      int dist[N];
      rep(i,N)dist[i]=INF;
      dist[C[s]]=0;
      Queue<int> q;
      q.push(C[s]);
      while(!q.empty()){
          int v=q.pop();
          for(int nv:G[v]){
              if(dist[v]+1<dist[nv]){
                  dist[nv]=dist[v]+1;
                  q.push(nv);
              }
          }
      }
      rep(t,K)table[s][t]=dist[C[t]];
  }

  int dp[1<<K][K];
  rep(i,1<<K)rep(j,K)dp[i][j]=INF;
  rep(bit,1<<K){
      if(popcnt(bit)==0){
          rep(j,K)dp[0][j]=0;
      }
      else if(popcnt(bit)==1){
          rep(j,K)dp[bit][j]=1;
      }
      else{
          rep(k,K)if((bit>>k)&1){
              int prebit=bit^(1<<k);
              rep(j,K)if((prebit>>j)&1){
                  if(dp[prebit][j]!=INF&&table[j][k]!=INF)chmin(dp[bit][k],dp[prebit][j]+table[j][k]);
              }
          }
      }
  }
  int ans=INF;
  rep(i,K)chmin(ans,dp[(1<<K)-1][i]);
  if(ans==INF)cout<<-1<<endl;
  else cout<<ans<<endl;
}
#include <bits/stdc++.h> 
using namespace std;

template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

#ifdef DEBUG
#define debug(args...) _debug(args)
void _debug(const char* format, ...) {
	va_list args;
	va_start(args, format);
	vprintf(format, args);
	va_end(args);
}
#else
#define debug(args...)
#endif

#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 105
#define EPS 1e-7

int n;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];

int main() {
	scanf("%d", &n);
	REP (_, 0, 2) {
		int x = 0, y = 0;
		REP (i, 0, n) {
			scanf("%d%d", &a[i], &b[i]);
			x += a[i];
			y += b[i];
			a[i] *= n;
			b[i] *= n;
		}
		REP (i, 0, n) {
			a[i] -= x;
			b[i] -= y;
		}
		swap(c, a);
		swap(d, b);
	}
	if (n == 1) {
		printf("Yes\n");
		return 0;
	}
	if (a[0] == 0 && b[0] == 0) {
		swap(a[0], a[1]);
		swap(b[0], b[1]);
	}
	REP (i, 0, n) {
		if (d[i] == c[i]) continue;
		ld angle = atan2(d[i], c[i]) - atan2(b[0], a[0]);
		bool pos = 1;
		REP (j, 0, n) {
			ld x = a[j] * cos(angle) - b[j] * sin(angle);
			ld y = a[j] * sin(angle) + b[j] * cos(angle);
			bool found = 0;
			REP (k, 0, n) {
				if (abs(x - c[k]) <= EPS && abs(y - d[k]) <= EPS) {
					found = 1;
					break;
				}
			}
			if (!found) {
				pos = 0;
				break;
			}
		}
		if (pos) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


/*
3
1 0
1 1
2 0
-1 0
-1 1
-3 0
*/
