#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; typedef tuple T; const int INF = 1000000000; const int MOD = 1000000007; int main(){ int n,m; cin >> n >> m; vector v(n); vector r(m); for(int i = 0;i < n;i++)cin >> v[i]; for(int i = 0;i < m;i++)cin >> r[i]; vector> dpv(n+1,vector(100000,0)); dpv[0][0] = 1; for(int i = 0;i < n;i++){ for(int j = 0;j <= 100000;j++){ if(j+v[i] <= 100000){ dpv[i+1][j+v[i]] += dpv[i][j]; dpv[i+1][j+v[i]] %= MOD; } dpv[i+1][j] += dpv[i][j]; dpv[i+1][j] %= MOD; } } vector> dpr(m+1,vector(100000,0)); dpr[0][0] = 1; for(int i = 0;i < m;i++){ for(int j = 0;j <= 100000;j++){ if(j+r[i] <= 100000){ dpr[i+1][j+r[i]] += dpr[i][j]; dpr[i+1][j+r[i]] %= MOD; } dpr[i+1][j] += dpr[i][j]; dpr[i+1][j] %= MOD; } } ll a,b; cin >> a >> b; vector v_accum(100001); for(int i = 1;i <= 100000;i++){ v_accum[i] = dpv[n][i]; } for(int i = 0;i <= 99999;i++){ v_accum[i+1] = v_accum[i+1] + v_accum[i]; v_accum[i+1] %= MOD; } ll ans = 0; for(int i = 1;i <= 100000;i++){ //a*i以上b*i以下の個数. if(a * i > 100000)break; ll cnt = (v_accum[min(b*i,100000LL)] - v_accum[a*i-1] + MOD) % MOD; ans += cnt * dpr[n][i] % MOD; } cout << ans << endl; }