//#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef long double ld; typedef pair Pii; typedef pair Pil; typedef pair Pll; typedef pair Pli; #define fi first #define se second #define mp make_pair const ll MOD = 1e9 + 7; const ll MOD2 = 998244353; const ll INF = 1ll << 60; const double PI = 2 * asin(1); void yes() {printf("yes\n");} void no() {printf("no\n");} void Yes() {printf("Yes\n");} void No() {printf("No\n");} void YES() {printf("YES\n");} void NO() {printf("NO\n");} int N, M, V[105], R[105], A, B; ll DPV[105][int(1e5 + 5)], DPR[105][int(1e5 + 5)]; ll SumV[int(1e5 + 5)], SumR[int(1e5 + 5)]; int main(){ scanf("%d%d", &N, &M); for (int i = 1; i <= N; i++) scanf("%d", V + i); for (int i = 1; i <= M; i++) scanf("%d", R + i); scanf("%d%d", &A, &B); DPV[0][0] = 1; for (int i = 1; i <= N; i++){ for (int j = 0; j <= 1e5; j++){ if (DPV[i - 1][j] == 0) continue; DPV[i][j] += DPV[i - 1][j]; DPV[i][j + V[i]] += DPV[i - 1][j]; } } SumV[0] = DPV[N][0]; for (int i = 1; i <= 1e5; i++){ SumV[i] = SumV[i - 1] + DPV[N][i]; } DPR[0][0] = 1; for (int i = 1; i <= M; i++){ for (int j = 0; j <= 1e5; j++){ if (DPR[i - 1][j] == 0) continue; DPR[i][j] += DPR[i - 1][j]; DPR[i][j + R[i]] += DPR[i - 1][j]; } } SumR[0] = DPR[M][0]; for (int i = 1; i <= 1e5 + 1; i++){ SumR[i] = SumR[i - 1] + DPR[M][i]; } ll ans = 0; for (int i = 1; i <= 1e5 + 1; i++){ if (SumR[i] == SumR[i - 1]) continue; ll now = SumR[i] - SumR[i - 1]; int nowA = A * i - 1, nowB = B * i; if (nowB > 1e5) nowB = 1e5 + 1; ans += now * (SumV[nowB] - SumV[nowA]); } printf("%lld\n", ans % MOD); return 0; }