#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; 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, m) { 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 sv(max_n+1, 0); sv[1] = dpv[n%2][1]; for(int i = 1; i < max_n; i++) { sv[i+1] = sv[i] + dpv[n%2][i+1]; sv[i+1] %= MOD; } ll ans = 0; for(int r = 1; b * r < max_n; r++){ ll num = sv[b * r] + MOD - sv[a * r - 1]; num %= MOD; ans += dpr[m%2][r] * num; ans %= MOD; } cout << ans << endl; }