import sys;input=sys.stdin.readline N, M = map(int, input().split()) X = list(map(int, input().split())) Y = list(map(int, input().split())) A, B = map(int, input().split()) sx = sum(X)+1 sy = sum(Y)+1 V = [0]*sx V[0] = 1 for i in range(N): x = X[i] for j in range(sx-1, -1, -1): if j-x>=0: V[j] += V[j-x] R = [0]*sy R[0] = 1 for i in range(M): x = Y[i] for j in range(sy-1, -1, -1): if j-x>=0: R[j] += R[j-x] SV = [0]*(sx+1) for i in range(1, sx+1): SV[i] = SV[i-1] + V[i-1] mod = 1000000007 rr = 0 for i in range(1, sy): r = R[i] a, b = min(i*A, sx), min(i*B+1, sx) rr = (rr+(SV[b]-SV[a])*r) % mod #print(SV) #print(V, R) print(rr)