#include<bits/stdc++.h>
using namespace std;
#define _rep(i, x, y) for(int i = (int)x; i < (int)y; ++i)
#define _dep(i,x,y) for(int i = (int)x; i > (int)y; i--)
#define PII pair<int,int>
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define PQ priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<ll> VL;
typedef vector<vector<ll>> VLL;
constexpr int mod = 1e9 + 7;
constexpr ll KINF = 1e18;
constexpr double eps = 1e-7;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	ll x;
	cin >> n >> x;
	VI a(n);
	_rep(i, 0, n) cin >> a[i];
	auto check = [&](int k){
		int rem = x % k;
		int b[n];
		_rep(i, 0, n) b[i] = a[i] % k;
		int dp[n + 1][k + 1][k + 1];
		memset(dp, -0x3f, sizeof dp);
		_rep(i, 0, n + 1) dp[i][0][0] = 0;
		_rep(i, 1, n + 1)
			_rep(j, 1, k + 1)
				_rep(z, 0, k){
					dp[i][j][z] = dp[i - 1][j][z];
					if(z - b[i - 1] >= 0) dp[i][j][z] = max(dp[i][j][z], dp[i - 1][j - 1][z - b[i - 1]] + a[i - 1]);
					else dp[i][j][z] = max(dp[i][j][z], dp[i - 1][j - 1][z + k - b[i - 1]] + a[i - 1]);
					if(dp[n][k][rem] == x) return 0;
				}
		return dp[n][k][rem];
	};
	int res = -1;
	vector<PII> ans;
	_dep(k, n, 1){
		res = check(k);
		if(res > 0) {
			ans.eb(res, k);
		}
		if(res == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	if(ans.empty()) {
		sort(all(a));
		// auto  it = lb(all(a), x);
		// if(it != a.end()) cout << x - *it << endl;
		// else cout << x - a[n - 1] << endl;
		cout << x - a[n - 1] << endl;
		return 0;
	}
	else{
		ll res = KINF;
		for(auto& [ini, div] : ans){
			res = min(res, (x - ini) / div);
		}
		cout << res << endl;
	}
	return 0;
} 
// 小心左移运算符导致的int溢出
// dp记得处理非法状态
// resize并不会初始化数组
// 全局函数一定要记得inline
// 带空格字符串不能直接cin,要用getline


#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define st first
#define nd second
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii; 
typedef vector<vi> vvi;  
#define sz(a) int((a).size()) 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>b;i--)
#define endl "\n"
#define fre freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
#define start ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define N 200005

//2 4 4 +1
// 


ll yen[20][1<<20];
queue<pair<int,int>> q;
vector<int> v[N];
ll vis[N];
ll dp[20][20];
ll k;
int idx[N];
vector<int> c;
ll sum=0;
bool check=true;


void solve()
{
int n,m;
cin>>n>>m;


rep(i,0,m)
{
	int a,b;
	cin>>a>>b;
	v[a].pb(b);v[b].pb(a);
}

cin>>k;
memset(idx,-1,sizeof(idx));
rep(i,0,k)
{
	int a;
	cin>>a;
	c.pb(a);
	idx[c[i]]=i;
}



rep(i,0,k)
{
	memset(vis,0,sizeof(vis));
	q.push(make_pair(c[i],0));

	rep(j,0,k)
	{
		dp[i][j]=N;
	}
	while(!q.empty())
	{
		ll temp=q.front().st;
		ll cur=q.front().nd;
		q.pop();
		if(vis[temp])
			continue;
		vis[temp]=1;
		if(idx[temp] != -1) dp[i][idx[temp]] = cur;
		rep(j,0,v[temp].size())
		{
			if(vis[v[temp][j]])
				continue;
			q.push({v[temp][j],cur+1});
		}
	}
}

memset(yen, N, sizeof(yen));
    for (int i=0; i<k; i++) yen[i][1<<i] = 0;
    
    for (int j=0; j<(1<<k); j++) {
        for (int i=0; i<k; i++) if (j & (1<<i)) {
            int cur = j & ~(1<<i);
            for (int l=0; l<k; l++) if (cur & (1<<l)) {
                yen[i][j] = min(yen[i][j], yen[l][cur] + dp[l][i]);
            }
        }
    }

    ll ans = N;
    for (int i=0; i<k; i++) ans = min(ans, yen[i][(1<<k)-1]);

    if (ans == N) cout<<-1<<endl;
    else cout<<ans+1<<endl;

}

int main(){
	start
	
	int t=1;
	//cin>>t;
	rep(i,0,t)
	solve();
}