#include #include using namespace std; using ll = long long int; constexpr ll MOD = 1'000'000'007; int main(){ int n, m; cin >> n >> m; vector v(n), r(m); for(auto &p: v) cin >> p; for(auto &p: r) cin >> p; int a, b; cin >> a >> b; const int cntlim = 100010; vector vcnt(cntlim, 0), rcnt(cntlim, 0); vcnt[0] = rcnt[0] = 1; for(auto &p: v){ for(int i = cntlim-1; i >= 0; i--){ if(vcnt[i] > 0) vcnt[i+p] += vcnt[i]; } } for(auto &p: r){ for(int i = cntlim-1; i >= 0; i--){ if(rcnt[i] > 0) rcnt[i+p] += rcnt[i]; } } for(int i = 1; i < cntlim; i++) rcnt[i] += rcnt[i-1]; //for(int i = 0; i < 20; i++) cerr << vcnt[i] << " "; ll ans = 0; for(int v1 = 1; v1 < cntlim; v1++){ int r1 = v1/a; int r2 = (v1+b-1)/b; if(r1 < r2) continue; //cerr << r1 << " " << r2 << endl; ans += vcnt[v1]*(rcnt[r1]-rcnt[r2-1]); ans %= MOD; } cout << ans << endl; return 0; }