#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long typedef vector VI; typedef pair pii; typedef vector VP; typedef vector VS; typedef priority_queue PQ; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i, greater > q2; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; VI V(N), R(M); REP(i, N)cin >> V[i]; REP(i, M)cin >> R[i]; int A, B; cin >> A >> B; SORT(V); SORT(R); int dp1[2][100010] = { 0 }, dp2[2][100010] = { 0 }; dp1[0][0] = dp2[0][0] = 1; REP(i, N) { REP(j, 100010) { dp1[(i + 1) % 2][j] += dp1[i % 2][j]; if (j + V[i] < 100010) { dp1[(i + 1) % 2][j + V[i]] += dp1[i % 2][j]; } } REP(j, 100010)dp1[i % 2][j] = 0; } REP(i, M) { REP(j, 100010) { dp2[(i + 1) % 2][j] += dp2[i % 2][j]; if (j + R[i] < 100010) { dp2[(i + 1) % 2][j + R[i]] += dp2[i % 2][j]; } } REP(j, 100010)dp2[i % 2][j] = 0;; } int ans = 0; int cnt[100010] = { 0 }; cnt[0] = dp1[N % 2][0]; FOR(i, 1, 100010) { cnt[i] = cnt[i - 1] + dp1[N % 2][i]; cnt[i] %= mod; } FOR(i, 1, 100010) { int ma = B * i, mi = A * i; mi--; if (mi >= 100000) { continue; } chmin(ma,100000LL); chmin(mi,100000LL); if (mi == -1) { ans += cnt[ma] * dp2[M % 2][i]; } else ans += (cnt[ma] - cnt[mi] + mod)*dp2[M % 2][i]; ans %= mod; } cout << ans << endl; return 0; }