#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; ll ceil(ll a, ll b){ return (a + b - 1) / b; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll MOD = 1e9 + 7; ll n, m; cin >> n >> m; vector v(n), r(m); rep(i, n) cin >> v[i]; rep(i, m) cin >> r[i]; ll a, b; cin >> a >> b; int max_n = 101010; ll dpv[2][max_n]; rep(i, 2) rep(j, max_n) dpv[i][j] = 0; dpv[0][0] = 1; rep(i, n) { rep(j, max_n) dpv[(i+1)%2][j] = 0; rep(j, max_n){ dpv[(i+1)%2][j] += dpv[i%2][j]; dpv[(i+1)%2][j] %= MOD; if(j + v[i] < max_n){ dpv[(i+1)%2][j+v[i]] += dpv[i%2][j]; dpv[(i+1)%2][j+v[i]] %= MOD; } } } ll dpr[2][max_n]; rep(i, 2) rep(j, max_n) dpr[i][j] = 0; dpr[0][0] = 1; rep(i, n) { rep(j, max_n) dpr[(i+1)%2][j] = 0; rep(j, max_n){ dpr[(i+1)%2][j] += dpr[i%2][j]; dpr[(i+1)%2][j] %= MOD; if(j + r[i] < max_n){ dpr[(i+1)%2][j+r[i]] += dpr[i%2][j]; dpr[(i+1)%2][j+r[i]] %= MOD; } } } vector sr(max_n+1, 0); sr[1] = dpr[m%2][1]; for(int i = 1; i < max_n; i++) { sr[i+1] = sr[i] + dpr[m%2][i+1]; sr[i+1] %= MOD; } ll ans = 0; for(int i = 1; i < max_n; i++){ if(ceil((ll)i, b) - 1 < 0) continue; ll num = sr[i / a] + MOD - sr[ceil((ll)i, b) - 1]; num %= MOD; ans += dpv[n%2][i] * num; ans %= MOD; } cout << ans << endl; }