#define ENABLE_DEBUG 1 // hidden common codes{{{ #include #define ALL(v) std::begin(v),std::end(v) using lint=long long; using ld=long double; template using numr=std::numeric_limits; struct input_t { template operator T() { T t; std::cin>>t; return t; } } input; #ifdef NGTKANA #include #else #define DEBUG(...)(void)0 #endif /*}}}*/ // mint {{{ template struct modint { using value_type = typename ModType::value_type; using mint = modint; static value_type mod() { return ModType::value; } static value_type inverse(value_type x) { value_type y=1,u=mod(),v=0; while(x){ value_type q=u/x; u-=q*x; std::swap(x,u); v-=q*y; std::swap(y,v); } assert(x==0 && std::abs(y)==mod() && std::abs(u)==1 && std::abs(v) modint(T t) : value([t] () mutable { if ( t <= -static_cast(mod()) || static_cast(mod()) <= t ) t %= mod(); return t < 0 ? t + mod() : t; }()) {} // operators mint& operator+= (mint y) { value += y.value; if (mod() <= value) value -= mod(); return *this; } mint& operator-= (mint y) { value -= y.value; if ( value < 0 ) value += mod(); return *this; } mint& operator*= (mint y) { value = (long long)value * y.value % mod(); return *this; } mint& operator/= (mint y) { value = (long long)value * inverse(y.value) % mod(); return *this; } mint& operator++() { return *this+=1; } mint& operator--() { return *this-=1; } mint& operator++(int) { mint this_=*this; *this++; return this_; } mint& operator--(int) { mint this_=*this; *this--; return this_; } // member functions mint& add(mint y) { return *this+=y; } mint& sub(mint y) { return *this-=y; } mint& mul(mint y) { return *this*=y; } mint& div(mint y) { return *this/=y; } mint& inv() { value = inverse(value); return *this; } mint added(mint y) { mint ans=*this; return ans.add(y); } mint subed(mint y) { mint ans=*this; return ans.sub(y); } mint muled(mint y) { mint ans=*this; return ans.mul(y); } mint dived(mint y) { mint ans=*this; return ans.div(y); } mint inved() { mint ans=*this; return ans.inv(); } static mint m1pow(long long y) { return y%2?-1:1; } static mint pow(mint x, unsigned long long y) { mint ans=1; for(;y;y>>=1){ if(y&1ull) ans*=x; x*=x; } return ans; } mint& powed(unsigned long long y){ return *this=pow(*this, y); } template mint map(F const& f){ value=f(value); return *this; } }; template std::ostream& operator<<(std::ostream& os, modint x) { return os << x.value; } template modint operator+(modint x, modint y) { return x+=y; } template modint operator-(modint x, modint y) { return x-=y; } template modint operator*(modint x, modint y) { return x*=y; } template modint operator/(modint x, modint y) { return x/=y; } template bool operator==(modint x, modint y) { return x.value==y.value; } template bool operator!=(modint x, modint y) { return x.value!=y.value; } template modint operator+(modint x, U y) { return x+modint(y); } template modint operator-(modint x, U y) { return x-modint(y); } template modint operator*(modint x, U y) { return x*modint(y); } template modint operator/(modint x, U y) { return x/modint(y); } template bool operator==(modint x, U y) { return x==modint(y); } template bool operator!=(modint x, U y) { return x!=modint(y); } template modint operator+(U x, modint y) { return modint(x)+y; } template modint operator-(U x, modint y) { return modint(x)-y; } template modint operator*(U x, modint y) { return modint(x)*y; } template modint operator/(U x, modint y) { return modint(x)/y; } template bool operator==(U x, modint y) { return modint(x)==y; } template bool operator!=(U x, modint y) { return modint(x)!=y; } using mod_type = int; constexpr mod_type mod = 1'000'000'007; using mint = modint< std::integral_constant >; //}}} int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); auto make=[&](auto&&a){ lint N=std::accumulate(ALL(a),0ll); std::vectordp(N+1,0); dp.at(0)=1; for(lint x:a){ for(lint i=N-x;i>=0;i--){ dp.at(i+x)+=dp.at(i); } } return dp; }; lint n=input,m=input; std::vectora(n),b(m); for(lint&x:a)x=input; for(lint&x:b)x=input; lint min=input,max=input; auto da=make(a),db=make(b); lint A=da.size()-1,B=db.size()-1; da.insert(da.begin(), 0); std::partial_sum(ALL(da),da.begin()); mint ans=0; for(lint j=1;j<=B;j++){ lint l=min*j, r=max*j; if(A