#include int main(){ using namespace std; constexpr unsigned long MOD = 1000000007; unsigned long N, M, Sv{1}, Sr{1}; cin >> N >> M; vector dp1{1}, dp2{1}; dp1.reserve(50000); dp2.reserve(50000); for(unsigned long i{0}, V; i < N; ++i){ cin >> V; dp1.resize(Sv += V); for(unsigned long j{Sv}; j-- > V; )(dp1[j] += dp1[j - V]) %= MOD; } for(unsigned long i{0}, R; i < M; ++i){ cin >> R; dp2.resize(Sr += R); for(unsigned long j{Sr}; j-- > R; )(dp2[j] += dp2[j - R]) %= MOD; } partial_sum(dp1.rbegin(), dp1.rend(), dp1.rbegin()); const auto& access = [&Sv, &dp1](long i) -> unsigned long { if(i < Sv)return dp1[i] %= MOD; return 0; }; unsigned long A, B; cin >> A >> B; unsigned long ans{0}; for(unsigned long i{1}; i < Sr; ++i)ans += dp2[i] * (access(A * i) + MOD - access(B * i + 1)) % MOD; cout << ans << endl; return 0; }