#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) #define endl "\n" int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); const ll mod = 1e9 + 7; ll n, m; cin >> n >> m; vector v(n); ll sumv = 0; rep(i, n) { cin >> v[i]; sumv += v[i]; } vector r(m); ll sumr = 0; rep(i, m) { cin >> r[i]; sumr += r[i]; } ll a, b; cin >> a >> b; vector vdp(sumv + 1, 0); vdp[0] = 1; rep(i, n) { rreps(j, v[i], sumv + 1) { vdp[j] = (vdp[j] + vdp[j - v[i]]) % mod; } } rep(i, sumv + 1) { if (i > 0) vdp[i] += vdp[i - 1]; } vector rdp(sumr + 1, 0); rdp[0] = 1; rep(i, m) { rreps(j, r[i], sumr + 1) { rdp[j] = (rdp[j] + rdp[j - r[i]]) % mod; } } ll ans = 0; reps(i, 1, sumr + 1) { ll l = a * i; ll r = b * i; if (l > sumv) continue; ll lv = (l == 0) ? 0 : vdp[l - 1]; ll rv = (r > sumv) ? vdp[sumv] : vdp[r]; ll cnt = max(0LL, rv - lv); ans = (ans + rdp[i] * cnt) % mod; } cout << ans << endl; return 0; }