#include using namespace std; inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template inline string toString(T x) {ostringstream sout;sout< VI; typedef vector VVI; typedef vector VL; typedef vector> VVL; typedef vector VS; typedef pair P; typedef tuple tpl; #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c).end()) #define REVERSE(c) reverse((c).begin(),(c).end()) #define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin() #define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin() #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i) #define RREP(i,n) RFOR(i,n,0) #define en "\n" constexpr double EPS = 1e-9; constexpr double PI = 3.141592653589793238462643383279; constexpr int INF = 2147483647; constexpr long long LINF = 1LL<<60; constexpr long long MOD = 1000000007; // 998244353 #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } struct mint { long long x; mint(long long x=0):x((x%MOD+MOD)%MOD){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) { if ((x += MOD-a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res+=a; } mint operator-(const mint a) const { mint res(*this); return res-=a; } mint operator*(const mint a) const { mint res(*this); return res*=a; } mint pow(long long t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime MOD mint inv() const { return pow(MOD-2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res/=a; } }; struct combination { vector fact, ifact; combination(long long n):fact(n+1),ifact(n+1) { assert(n < MOD); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i; } mint operator()(long long n, long long k) { if (k < 0 || k > n) return 0; return fact[n]*ifact[k]*ifact[n-k]; } }; int main(void){ ll N,M; cin >> N >> M; VL V(N), R(M); ll sumv = 0, sumr = 0; REP(i,N){ cin >> V[i]; sumv += V[i]; } REP(i,M){ cin >> R[i]; sumr += R[i]; } ll A,B; cin >> A >> B; VL sv2(sumv+1,0), sr2(sumr+1,0); sv2[0] = 1; sr2[0] = 1; REP(i,N)RREP(j,sumv+1){ if(j-V[i] < 0) continue; (sv2[j] += sv2[j-V[i]]) %= MOD; } REP(i,N)RREP(j,sumr+1){ if(j-R[i] < 0) continue; (sr2[j] += sr2[j-R[i]]) %= MOD; } VL sv(sumv+1,0), sr(sumr+1,0); sv[0] = 1; sr[0] = 1; REP(i,sumv) (sv[i+1] += sv[i] + sv2[i+1]) %= MOD; REP(i,sumr) (sr[i+1] += sr[i] + sr2[i+1]) %= MOD; mint ans; REP(i,sumr){ ans += sr2[i+1]*sv[min(sumv, (i+1)*B)]; } REP(i,sumr){ ans -= sr2[i+1]*sv[min(sumv, (i+1)*A-1)]; } cout << ans.x << endl; return 0; }