#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; const ll MOD = 1000000007; const ll INF = 2147483647; const ll LINF = 9223372036854775807; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() const int MAX=100001; int main() { int n, m; cin >> n >> m; VI v(n), r(m); REP(i,n) cin >> v[i]; REP(i,m) cin >> r[i]; int a, b; cin >> a >> b; VI pv(MAX+1,0), pr(MAX+1,0); pv[0]=1; pr[0]=1; REP(i,n)for(int j=MAX;j>=v[i];j--){ pv[j]+=pv[j-v[i]]; pv[j]%=MOD; } REP(i,m)for(int j=MAX;j>=r[i];j--){ pr[j]+=pr[j-r[i]]; pr[j]%=MOD; } REP(i,MAX){ pv[i+1]+=pv[i]; pv[i+1]%=MOD; } ll ans=0; for(int i=1;i<=MAX;i++){ if(pr[i]==0) continue; ll l=a*i, rr=min(MAX,b*i); if(l>MAX) break; ans+=pr[i]*(pv[rr]-pv[l-1]); ans%=MOD; } cout << ans << endl; return 0; }