#include using namespace std; constexpr int mod = 1000000007; constexpr int N = 100; constexpr int M = 1000; constexpr int A = N * M; long long dpv[A+10], dpr[A+10]; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector v(n), r(m); for (auto &x: v) cin >> x; for (auto &x: r) cin >> x; int a, b; cin >> a >> b; auto dp = [&](auto &v, auto &dpv) { dpv[0] = 1; for (auto &x: v) { for (int i = A; i >= x; i--) { dpv[i] = (dpv[i] + dpv[i-x]) % mod; } } }; dp(v, dpv), dp(r, dpr); for (int i = A; i > 0; i--) { dpv[i-1] = (dpv[i-1] + dpv[i]) % mod; } long long ans = 0; for (int ri = 1; ri <= A; ri++) { // ri * a <= v <= ri * b if (ri * a > A) break; ans += dpr[ri] * (dpv[ri*a] - dpv[min(ri*b, A)+1] + mod) % mod; } cout << ans % mod << "\n"; return 0; }