#include "bits/stdc++.h" #define int long long #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(obj) begin(obj), end(obj) #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) #define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key)) #define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key)) using namespace std; using ll = long long; const int MOD = (int)(1e9 + 7); const int INF = (int)(1e13 + 7); int ceil_(int a, int b) { return (a + (b - 1)) / b; } int bpm(int x, unsigned int y) { if (x == 0) return 0; if (y == 0) return 1; int ans = 1; int digit = (int)((log((double)y) / log((double)2) / 1 + 1)); x %= MOD; for (unsigned int i = 0; i < digit; i++) { if (((y >> i) & 1u) == 1) ans = ans * x % MOD; x = x * x % MOD; } return ans; } template void cumulative_sum(T &container) { for (int i = 0; i < container.size() - 1; i++) container[i + 1] = (container[i + 1] + container[i]) % MOD; } signed main() { int N, M; cin >> N >> M; vector V(N); vector R(M); rep(i, N) cin >> V[i]; rep(i, M) cin >> R[i]; int A, B; cin >> A >> B; vector resist(100000 + 10000, 0); vector electricity(100000 + 10000, 0); resist[0] = 1; electricity[0] = 1; rep(i, M) { for (int j = 100010; j >= 0; j--) { if (j - R[i] >= 0) resist[j] = (resist[j] + resist[j - R[i]]) % MOD; } } rep(i, N) { for (int j = 100010; j >= 0; j--) { if (j - V[i] >= 0) electricity[j] = (electricity[j] + electricity[j - V[i]]) % MOD; } } cumulative_sum(electricity); int ans = 0; rep(i, 100010) { if (A * (i + 1) > 100000) break; ans = (ans + (resist[i + 1] * ((electricity[min(B * (i + 1), 100010LL)] - electricity[A * (i + 1) - 1LL]) % MOD)) % MOD) % MOD; } cout << ans << endl; }