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()) sumv = sum(V) sumr = sum(R) dpv = [0] * (sumv + 11) dpr = [0] * (sumr + 1) dpv[0] = 1 dpr[0] = 1 for v in V: for i in reversed(range(sumv - v + 1)): dpv[i + v] += dpv[i] for r in R: for i in reversed(range(sumr - r + 1)): dpr[i + r] += dpr[i] dpv[0] = 0 dpr[0] = 0 SV = dpv[:] for i in range(sumv + 10): SV[i+1] += SV[i] ans = 0 for r in range(sumr+1): if dpr[r] > 0: minv = min(A * r, sumv + 10) maxv = min(B * r, sumv + 10) ans += dpr[r] * (SV[maxv] - SV[minv - 1]) ans %= MOD print(ans)