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