#include using namespace std; long long MOD = 1000000007; long long MAX = 200000; long long modsub(long long A, long long B){ return (A % MOD - B % MOD + MOD) % MOD; } int main(){ int N, M; cin >> N >> M; vector V(N); for (int i = 0; i < N; i++){ cin >> V[i]; } vector R(M); for (int i = 0; i < M; i++){ cin >> R[i]; } long long A, B; cin >> A >> B; vector dpV(MAX, 0); dpV[0] = 1; for (int i = 0; i < N; i++){ vector dp2 = dpV; for (int j = V[i]; j < MAX - V[i]; j++){ dp2[j] = (dp2[j] + dpV[j - V[i]]) % MOD; } dpV = dp2; } vector dpR(MAX, 0); dpR[0] = 1; for (int i = 0; i < M; i++){ vector dp2 = dpR; for (int j = R[i]; j < MAX - R[i]; j++){ dp2[j] = (dp2[j] + dpR[j - R[i]]) % MOD; } dpR = dp2; } vector sum(MAX, 0); sum[0] = dpV[0]; for (int i = 1; i < MAX; i++){ sum[i] = (sum[i - 1] + dpV[i]) % MOD; } long long ans = 0; for (int i = 1; i < MAX; i++){ long long ub = sum[min(MAX - 1, B * i)]; long long lb = sum[min(MAX - 1, A * i - 1)]; ans = (ans + dpR[i] * modsub(ub, lb) % MOD) % MOD; } cout << ans << endl; }