N, M = map(int, input().split()) V = tuple(map(int, input().split())) R = tuple(map(int, input().split())) A, B = map(int, input().split()) MOD = 10 ** 9 + 7 MAX = 10 ** 5 + 1 dpv = [[0] * MAX for _ in range(N + 1)] dpv[0][0] = 1 for i in range(N): for j in range(MAX): if j >= V[i]: dpv[i + 1][j] = (dpv[i][j - V[i]] + dpv[i][j]) % MOD else: dpv[i + 1][j] = dpv[i][j] dpr = [[0] * MAX for _ in range(M + 1)] dpr[0][0] = 1 for i in range(M): for j in range(MAX): if j >= R[i]: dpr[i + 1][j] = (dpr[i][j - R[i]] + dpr[i][j]) % MOD else: dpr[i + 1][j] = dpr[i][j] v_sum = [0] * MAX for i in range(MAX - 1): v_sum[i + 1] = (v_sum[i] + dpv[N][i]) % MOD ans = 0 for i in range(1, MAX): l, r = A * i, min(MAX - 1, B * i + 1) if l >= MAX: break ans = (ans + (v_sum[r] - v_sum[l]) * dpr[M][i]) % MOD print(ans)