#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define ALL(v) v.begin(),v.end() #define FOR(i, j, k) for(ll i=j;i llvec; typedef vector dvec; typedef pair P; typedef long double ld; struct Edge{ll from, to, cost;}; struct node{ll cost, to; bool friend operator>(node a, node b){ return a.cost>b.cost; } }; ll mod(ll a, ll mod){ ll res = a%mod; if(res<0)res=res + mod; return res; } ll modpow(ll a, ll n, ll mod){ ll res=1; while(n>0){ if(n&1) res=res*a%mod; a=a*a%mod; n>>=1; } return res; } ll modinv(ll a, ll mod){ return modpow(a, mod-2, mod); } ll gcd(ll a, ll b){ ll r = a%b; if(r==0) return b; else return gcd(b, a%b); } bool is_prime(ll n){ ll i = 2; if(n==1)return false; if(n==2)return true; bool res = true; while(i*i =100100)return 0; if(dpV[n][v]>=0){ return dpV[n][v]; }else{ dpV[n][v]=0; if(n==0)dpV[n][v]=1; else{ dpV[n][v]=dpfV(n-1, v)%MOD; if(v-V[n-1]>=0){ dpV[n][v] =mod(dpV[n][v]+dpfV(n-1, v-V[n-1]), MOD); } } return dpV[n][v]; } } ll dpfR(ll n, ll v){ if(n<0 or v>=100100)return 0; if(dpR[n][v]>=0){ return dpR[n][v]; }else{ dpR[n][v]=0; if(n==0){ if(v==0)dpR[n][v]=1; } else{ dpR[n][v]=dpfR(n-1, v)%MOD; if(v-R[n-1]>=0){ dpR[n][v] =mod(dpR[n][v]+dpfR(n-1, v-R[n-1]), MOD); } } return dpR[n][v]; } } /************************************** ** A main function starts from here ** ***************************************/ int main(){ cin >> N >> M; rep(i, N)cin >> V[i]; rep(i, M)cin >> R[i]; cin >> A >> B; fill(dpV[0], dpV[101], -100); fill(dpR[0], dpR[101], -100); ll ans = 0; rep(i, 100000){ ll vnum = mod(dpfV(N, (i+1)*B) - dpfV(N, (i+1)*A - 1),MOD); //cout << vnum << endl; ans = mod(ans+dpfR(M, i+1)*vnum,MOD); } cout << ans; return 0; }