#include #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using namespace std; using ll = long long; using ld = long double; template inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; } constexpr int MOD = 1e9+7; //constexpr int MOD = 998244353; struct mint { long long x; mint(long long x = 0) noexcept : x((x%MOD + MOD) % MOD) {} // basis mint operator-() const { return mint(-x); } mint& operator+=(const mint a) noexcept { if((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) noexcept { if((x += MOD-a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint a) noexcept { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const noexcept { return mint(*this) += a; } mint operator-(const mint a) const noexcept { return mint(*this) -= a; } mint operator*(const mint a) const noexcept { return mint(*this) *= a; } mint mpow(long long t) const noexcept { if(!t) return 1; mint a = mpow(t>>1); a *= a; if(t&1) a *= *this; return a; } // for prime MOD mint inv() const noexcept { return mpow(MOD-2); } mint& operator/=(const mint a) noexcept { return *this *= a.inv(); } mint operator/(const mint a) const noexcept { return mint(*this) /= a; } // comparison bool operator==(const mint &a) const noexcept { return this->x == a.x; } bool operator!=(const mint &a) const noexcept { return this->x != a.x; } // I/O stream friend istream& operator>>(istream& is, mint& a) noexcept { return is >> a.x; } friend ostream& operator<<(ostream& os, const mint& a) noexcept { return os << a.x; } }; // additional mint mpow(const long long &a, long long n) noexcept { return mint(a).mpow(n); } mint mpow(const mint &a, long long n) noexcept { return a.mpow(n); } const int MXN = 100, MXV = 1000, MXM = 100, MXR = 1000; ll n, m, v[MXN], r[MXM], a, b; mint dpv[MXN+10][(MXN+2)*MXV], dpr[MXM+10][(MXM+2)*MXR]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; rep(i, n) cin >> v[i]; rep(i, m) cin >> r[i]; cin >> a >> b; dpv[0][0] = 1; rep(i, n) rep(j, n*MXV+1) { dpv[i+1][j] += dpv[i][j]; dpv[i+1][j+v[i]] += dpv[i][j]; } dpr[0][0] = 1; rep(i, m) rep(j, m*MXR+1) { dpr[i+1][j] += dpr[i][j]; dpr[i+1][j+r[i]] += dpr[i][j]; } vector sum((MXN+2)*MXV, 0); for(int i = 0; i <= MXN*MXV; i++) sum[i+1] += sum[i]+dpv[n][i]; mint ans = 0; for(ll i = 0; i <= MXN*MXV+1; i++) { if(a*i > MXN*MXV+1) continue; mint cnt = sum[min(MXN*MXV, b*i)+1]-sum[a*i]; ans += cnt*dpr[n][i]; } ans -= 1; cout << ans << '\n'; return 0; }