#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++){ for (int j = MAX - 1; j >= V[i]; j--){ dpV[j] += dpV[j - V[i]]; dpV[j] %= MOD; } } vector dpR(MAX, 0); dpR[0] = 1; for (int i = 0; i < N; i++){ for (int j = MAX - 1; j >= R[i]; j--){ dpR[j] += dpR[j - R[i]]; dpR[j] %= MOD; } } vector sum(MAX + 1, 0); for (int i = 0; i < MAX; i++){ sum[i + 1] = sum[i] + dpV[i]; sum[i + 1] %= MOD; } long long ans = 0; for (int i = 1; i < MAX; i++){ long long ub = sum[min(MAX, B * i + 1)]; long long lb = sum[min(MAX, A * i)]; ans = (ans + dpR[i] * modsub(ub, lb) % MOD) % MOD; } cout << ans << endl; }