#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define PB push_back #define MP(A, B) make_pair(A, B) #define fi first #define se second #define gcd(a,b) __gcd(a,b) #define pi acos(-1.0) #define pii pair #define ll long long #define MAX 1000005 #define MOD 1000000007 #define INF 0x3f3f3f3f #define EXP 1e-8 #define lowbit(x) (x&-x) ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;} struct hash_pair { template size_t operator()(const pair& p) const { auto hash1 = hash{}(p.first); auto hash2 = hash{}(p.second); return hash1 ^ hash2; } }; int v[105] = {0}, r[105] = {0}; unordered_map vp, rp; unordered_map vpa, rpa; vector vl, rl; int main() { int n, m, a, b; long long ans = 0; cin >> n >> m; for (int i = 0; i < n; ++i) cin >> v[i]; for (int i = 0; i < m; ++i) cin >> r[i]; cin >> a >> b; for (int i = 0; i < n; ++i) { vpa = vp; int vll = vl.size(); long long vn = v[i]; if (!vp.count(vn)) vl.push_back(vn); vpa[vn]++; vpa[vn] %= MOD; for (int j = 0; j < vll; ++j) { if (!vp.count(vn + vl[j])) { vl.push_back(vn + vl[j]); } vpa[vn+vl[j]] += vp[vl[j]]; vpa[vn+vl[j]] %= MOD; } vp = vpa; } for (int i = 0; i < m; ++i) { rpa = rp; int rll = rl.size(); ll rn = r[i]; if (!rp.count(rn)) rl.push_back(rn); rpa[rn]++; rpa[rn] %= MOD; for (int j = 0; j < rll; ++j) { if (!rp.count(rn + rl[j])) { rl.push_back(rn + rl[j]); } rpa[rn+rl[j]]+=rp[rl[j]]; rpa[rn+rl[j]] %= MOD; } rp = rpa; } int min_j = 0, flag = 0; for (int i = 0; i < vl.size(); ++i) { flag = 0; for (int j = min_j; j < rl.size(); ++j) { double ii = (double)vl[i] / (double)rl[j]; if (ii <= b && ii >= a) { if (!flag) { flag = 1; min_j = max(min_j, j); } ans += (vp[vl[i]] % MOD) * (rp[rl[j]]% MOD) % MOD; // cout << vl[i] << ' ' << vp[vl[i]] << endl; // cout << rl[j] << ' ' << rp[rl[j]] << endl; // cout << ans << endl; ans %= MOD; } } } cout << ans << endl; return 0; }