#include using namespace std; using ll = long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 60; #define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++) #define vi vector #define vl vector #define vvi vector> #define vvl vector> #define pint pair #define plong pair int main() { int N, M, A, B; cin>> N >> M; vi V(N + 1, 0), R(M + 1, 0); REP(i, 1, N + 1) cin >> V[i]; REP(i, 1, M + 1) cin >> R[i]; cin >> A >> B; vvl DPV(101, vl(100010, 0)); vvl DPR(101, vl(100010, 0)); REP(i, 0, N + 1) DPV[i][0] = 1; REP(i, 0, M + 1) DPR[i][0] = 1; REP(j, 1, N + 1){ REP(i, 1, 100001){ if(i - V[j] >= 0) DPV[j][i] += DPV[j - 1][i - V[j]]; DPV[j][i] += DPV[j - 1][i]; DPV[j][i] %= mod; } } REP(j, 1, M + 1){ REP(i, 1, 100001){ if(i - R[j] >= 0) DPR[j][i] += DPR[j - 1][i - R[j]]; DPR[j][i] += DPR[j - 1][i]; DPR[j][i] %= mod; } } vl sum(100010, 0); long ans = 0; REP(i, 1, 100001){ sum[i] = DPV[M][i] + sum[i - 1]; sum[i] %= mod; //if(i < 20) cout << sum[i] << " "; } REP(i, 1, 100001){ if(i * B <= 100000) ans += DPR[M][i] * (sum[i * B] - sum[i * A - 1]) + mod; ans %= mod; } cout << ans << endl; }