#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); const long long MOD = 1000000007; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector v(n), r(m); REP (i, n) cin >> v[i]; REP (i, m) cin >> r[i]; int a, b; cin >> a >> b; // v pattern vector pv(100000 + 1); pv[0] = 1; REP (i, n) for (int j = pv.size() - 1; j >= 0; j--) if (j >= v[i]) (pv[j] += pv[j-v[i]]) %= MOD; // r pattern vector pr(100000 + 1); pr[0] = 1; REP (i, m) for (int j = pr.size() - 1; j >= 0; j--) if (j >= r[i]) (pr[j] += pr[j-r[i]]) %= MOD; for (int i = 1; i < pr.size(); i++) (pr[i] += pr[i-1]) %= MOD; long long ret = 0; for (int i = 1; i < pv.size(); i++) { long long x = pv[i]; int rmin = (i + b - 1) / b; int rmax = i / a; long long y = pr[rmax] - pr[rmin-1]; y %= MOD; if (y < 0) y += MOD; (ret += x * y % MOD) %= MOD; } cout << ret << endl; return 0; }