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 S = sum(V) D = [0]*(10**5+2) for e in V: for k in range(10**5+1,-1,-1): if D[k] > 0: D[k+e] += D[k] D[e] += 1 T = [0]*(10**5+2) for e in R: for k in range(10**5+1,-1,-1): if T[k] > 0: T[k+e] += T[k] T[e] += 1 for k in range(1,10**5+1): D[k] += D[k-1] ans = 0 for k in range(1,sum(R)+1): ans += T[k]*(D[min(S,k*B)]-D[max(0,min(S,k*A-1))]) ans %= MOD print(ans)