#include using namespace std; #ifdef LOCAL #include "debug.h" #else #define DEBUG(...) #endif template > constexpr T power(T a, long long n, Op op = Op(), T e = {1}) { assert(n >= 0); while (n) { if (n & 1) e = op(e, a); if (n >>= 1) a = op(a, a); } return e; } template struct modular { using m = modular; static constexpr unsigned mod = M; unsigned v; modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {} m operator-() const { return m() -= *this; } m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; } m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; } m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; } m& operator/=(m b) { return *this *= power(b, mod - 2); } friend m operator+(m a, m b) { return a += b; } friend m operator-(m a, m b) { return a -= b; } friend m operator*(m a, m b) { return a *= b; } friend m operator/(m a, m b) { return a /= b; } friend bool operator==(m a, m b) { return a.v == b.v; } }; using mint = modular; constexpr int lim = 100 * 1000; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector dpv(lim + 2); dpv[0] = 1; for (int _ = n; _--; ) { int v; cin >> v; for (int x = lim - v; x >= 0; --x) { dpv[x + v] += dpv[x]; } } vector dpr(lim + 1); dpr[0] = 1; for (int _ = n; _--; ) { int r; cin >> r; for (int x = lim - r; x >= 0; --x) { dpr[x + r] += dpr[x]; } } for (int x = lim + 1; x--; ) { dpv[x] += dpv[x + 1]; } long long a, b; cin >> a >> b; mint res; for (int y = 1; y <= lim; ++y) { auto lb = min(a * y, lim + 1), ub = min(y * b + 1, lim + 1); res += dpr[y] * (dpv[lb] - dpv[ub]); } cout << res.v << '\n'; }