#include using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) using ll = long long; using P = pair; const int mod = 1000000007; int main() { int n,m; cin >>n >> m; vector v(n),r(m); ll V = 0; rep(i,n){ cin >> v[i]; V += v[i]; } ll R = 0; rep(i,m){ cin >> r[i]; R += r[i]; } ll a,b; cin >> a >> b; vector dpv(V+1),dpr(R+1); dpv[0] = 1; dpr[0] = 1; rep(i,n)for(ll j = V;j >= 0;--j){ if(j+ v[i] > V)continue; dpv[j+v[i]] += dpv[j]; dpv[j+v[i]] %= mod; if(dpv[j+v[i]] <0)dpv[j+v[i]] += mod; } rep(i,m)for(ll j = R;j >= 0;--j){ if(j+ r[i] > R)continue; dpr[j+r[i]] += dpr[j]; dpr[j+r[i]] %= mod; if(dpr[j+r[i]] <0)dpr[j+r[i]] += mod; } vector smv(V+2,0); rep(i,V+1){ smv[i+1] = smv[i] + dpv[i]; smv[i+1] %= mod; if (smv[i+1] < 0)smv[i+1] += mod; } ll ans = 0; rep(i,R+1){ if(!i)continue; if(!dpr[i])continue; ll vmin = a*i; ll vmax = b*i; ans += (smv[min(V+1,vmax+1)] - smv[min(V+1,vmin)])*dpr[i]; ans %= mod; if( ans < 0)ans += mod; } cout << ans << endl; return 0; }