#include using namespace std; using ll = long long; const ll mod = 1e9 + 7; const int MAX = 1e5 + 1; vector do_dp(vector a) { int n = a.size(); vector> dp(n + 1, vector(MAX)); //dp[i] := i個目まで見た時にjを作る個数 dp[0][0] = 1; for(int i = 0; i < n; i++) { for(int j = 0; j < MAX; j++) { dp[i + 1][j] += dp[i][j]; dp[i + 1][j] %= mod; if(j + a[i] < MAX) { dp[i + 1][j + a[i]] += dp[i][j]; dp[i + 1][j + a[i]] %= mod; } } } return dp[n]; } int main() { int n, m; cin >> n >> m; vector v(n), r(m); for(int i = 0; i < n; i++)cin >> v[i]; for(int i = 0; i < m; i++)cin >> r[i]; vector vnum = do_dp(v), rnum = do_dp(r); vector vsum(MAX + 1); for(int i = 0; i < MAX; i++) { vsum[i + 1] += vsum[i] + vnum[i]; vsum[i + 1] %= mod; } ll a, b; cin >> a >> b; ll ans = 0; for(int i = 0; i < MAX; i++) { ll lef = i * a, rig = i * b + 1; lef = min((ll)MAX, lef); rig = min((ll)MAX, rig); ll res = rnum[i] * (vsum[rig] - vsum[lef]); res %= mod; ans += res; ans %= mod; } cout << ((ans -1) % mod + mod) % mod << endl; }