#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using lint = long long int; long long int INF = 1001001001001001LL; int inf = 1000000007; long long int MOD = 1000000007LL; double PI = 3.1415926535897932; templateinline void chmin(T1 &a,const T2 &b){if(a>b) a=b;} templateinline void chmax(T1 &a,const T2 &b){if(a culc(vector a) { int n = a.size(); lint m = 100 * 1000; vector> dp(n + 1, vector (m + 1, 0)); dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= m; j++) { if (dp[i][j] == 0) continue; dp[i + 1][j] += dp[i][j]; dp[i + 1][j] %= MOD; dp[i + 1][j + a[i]] += dp[i][j]; dp[i + 1][j + a[i]] %= MOD; } } return dp[n]; } // 抽象累積和 // 構築 O(n), get O(1) template struct CumSum{ private: size_t n; vector dat; public: CumSum(const vector &v){ n = v.size(); dat.resize(n + 1, 0); for(size_t i = 0; i < n; i++){ dat[i + 1] = dat[i] + v[i]; dat[i + 1] %= MOD; } } T get(size_t r) const { // 0-indexed, [0. r) return dat[r]; } T get(size_t l, size_t r){ // 0-indexed, [l, r) return (dat[r] - dat[l] + MOD) % MOD; } }; int main() { int n, m; cin >> n >> m; vector v(n); vector r(m); for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = 0; i < m; i++) { cin >> r[i]; } lint a, b; cin >> a >> b; auto dp1 = culc(v); auto dp2 = culc(r); // 抵抗を決め打ち CumSum acc(dp1); lint ans = 0; for (int r = 1; r <= 100 * 1000; r++) { // 範囲が決ま lint lb = a * r; lint rb = b * r; // [l, r] rb = min(rb, (lint)dp1.size() - 1); if (rb <= lb) continue; lint sum = acc.get(lb, rb + 1); ans += sum * dp2[r]; ans %= MOD; } cout << ans << endl; return 0; }