typedef long long ll; typedef long double ld; #include using namespace std; ll const MOD = 1e9+7; int main() { ll n,m; std::cin >> n>>m; vector v(n),r(m); for (int i = 0; i < n; i++) { std::cin >> v[i]; } for (int i = 0; i < m; i++) { std::cin >> r[i]; } ll a,b; std::cin >> a>>b; vector> dpv(n+1,vector(100010,0)); vector> dpr(m+1,vector(100010,0)); dpv[0][0]++; dpr[0][0]++; for (int i = 0; i < n; i++) { for (int j = 0; j <= 100000; j++) { dpv[i+1][j] = dpv[i][j]; if(j-v[i]>=0) dpv[i+1][j] += dpv[i][j-v[i]]; dpv[i+1][j] %= MOD; } } for (int i = 0; i < m; i++) { for (int j = 0; j <= 100000; j++) { dpr[i+1][j] = dpr[i][j]; if(j-r[i]>=0) dpr[i+1][j] += dpr[i][j-r[i]]; dpr[i+1][j] %= MOD; } } vector rui(100010,0); for (int i = 1; i <= 100000; i++) { rui[i+1] = rui[i] + dpr[m][i]; rui[i+1] %= MOD; } ll ans = 0; for (int i = 1; i <= 100000; i++) { ans += dpv[n][i]*(rui[i/a+1]+MOD-rui[(i+b-1)/b])%MOD; ans %= MOD; } std::cout << ans << std::endl;}