N, M = map(int, input().split()) V = list(map(int, input().split())) R = list(map(int, input().split())) A, B = map(int, input().split()) MOD = 10**9 + 7 dpv = [0] * (10**5+1) dpv[0] = 1 for i in range(N): for j in range(10**5, -1, -1): if V[i] + j <= 10**5 and dpv[j] > 0: dpv[V[i]+j] += dpv[j] dpr = [0] * (10**5+1) dpr[0] = 1 for i in range(M): for j in range(10**5, -1, -1): if R[i] + j <= 10**5 and dpr[j] > 0: dpr[R[i]+j] += dpr[j] accv = [0] for i in range(10**5): accv.append(accv[i] + dpv[i+1]) ans = 0 for i in range(1, len(dpr)): if dpr[i] == 0: continue low = A * i - 1 hig = B * i num = (accv[hig] - accv[low]) * dpr[i] ans += (num % MOD) ans %= MOD print(ans)