MOD = 10 ** 9 + 7 n, m = map(int, input().split()) V = list(map(int, input().split())) R = list(map(int, input().split())) a, b = map(int, input().split()) W = sum(V) dp = [0] * (W + 1) dp[0] = 1 for v in V: for i in range(W, v - 1, -1): dp[i] += dp[i - v] dp[i] %= MOD for i in range(1, W + 1): dp[i] += dp[i - 1] dp[i] %= MOD W2 = sum(R) dp2 = [0] * (W2 + 1) dp2[0] = 1 for r in R: for i in range(W2, r - 1, -1): dp2[i] += dp2[i - r] dp2[i] %= MOD ans = 0 for i in range(1, W2 + 1): mi = a * i - 1 if mi >= W: break ma = min(b * i, W) ans += dp2[i] * (dp[ma] - dp[mi]) ans %= MOD print(ans)