mx = 101010 mod = 10 ** 9 + 7 def f(X): n = len(X) pre = [0] * mx pre[0] = 1 for i in range(n): dp = [0] * mx for j in range(mx): dp[j] += pre[j] if j - X[i] >= 0: dp[j] += pre[j - X[i]] dp[j] %= mod dp, pre = pre, dp return pre N, M = map(int, input().split()) V = list(map(int, input().split())) R = list(map(int, input().split())) A, B = map(int, input().split()) V = f(V) R = f(R) Vc = [0] * (mx + 1) for i in range(mx): Vc[i + 1] = Vc[i] + V[i] Vc[i + 1] %= mod ans = 0 for i in range(1, mx): ans += R[i] * (Vc[min(mx, i * B + 1)] - Vc[min(mx, i * A)]) ans %= mod print(ans)