n, m = map(int, input().split()) v = list(map(int, input().split())) r = list(map(int, input().split())) a, b = map(int, input().split()) MAX = 100010 mod = 10**9 + 7 dpv = [[0 for j in range(MAX)] for i in range(n+1)] dpr = [[0 for j in range(MAX)] for i in range(m+1)] dpv[0][0] = 1 for i in range(n): for j in range(MAX): if dpv[i][j] > 0: dpv[i+1][j] += dpv[i][j] dpv[i+1][j] %= mod if j + v[i] < MAX: dpv[i+1][j+v[i]] += dpv[i][j] if dpv[i+1][j+v[i]] >= mod: dpv[i+1][j+v[i]] -= mod dpr[0][0] = 1 for i in range(m): for j in range(MAX): if dpr[i][j] > 0: dpr[i+1][j] += dpr[i][j] dpr[i+1][j] %= mod if j + r[i] < MAX: if dpr[i+1][j+v[i]] >= mod: dpr[i+1][j+v[i]] -= mod vsum = [0 for _ in range(MAX)] for i in range(MAX-1): vsum[i+1] = vsum[i] + dpv[n][i] vsum[i+1] %= mod ans = 0 for i in range(1, MAX): L, R = a*i, min(MAX-1, b*i+1) if L >= MAX: break ans += (vsum[R] - vsum[L] + mod) % mod * dpr[m][i] % mod ans %= mod print(ans)