//#include #include using namespace std; typedef long long ll; typedef pair p; const int INF = 1e9; const ll LINF = ll(1e18); const int MOD = 1000000007; const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() #define debug(v) \ cout << #v << ":"; \ for (auto x : v) \ { \ cout << x << ' '; \ } \ cout << endl; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //cout< v, r; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; v.resize(n); r.resize(m); rep(i, n) cin >> v[i]; rep(i, m) cin >> r[i]; ll a, b; cin >> a >> b; vector dpv(1000001, 0), dpr(1000001, 0), sumv(1000001, 0), sumr(1000001, 0); dpv[0] = 1; dpr[0] = 1; rep(i, n) { for (int j = 1000000; j >= 0; j--) { if (j + v[i] <= 1000000) { dpv[j + v[i]] += dpv[j]; dpv[j + v[i]] %= MOD; } } } rep(i, m) { for (int j = 1000000; j >= 0; j--) { if (j + r[i] <= 1000000) { dpr[j + r[i]] += dpr[j]; dpr[j + r[i]] %= MOD; } } } ll sum_r = 0; ll sum_v = 0; for (int i = 1; i <= 1000000; i++) { sum_r += dpr[i]; sum_r %= MOD; sum_v += dpv[i]; sum_v %= MOD; sumr[i] = sum_r; sumv[i] = sum_v; } ll ans=0; for (ll i = 1; i <= 1000000; i++){ if(dpr[i]){ ll maxv=min(b*i,ll(1000000)); ll minv=min(a*i-1,ll(1000000)); ans+=dpr[i]*((sumv[maxv]-sumv[minv]+MOD)%MOD); ans%=MOD; } } cout<