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 M = 10**5+5 dpV = [0]*M dpR = [0]*M dpV[0] = 1 dpR[0] = 1 for v in V: for i in range(M)[::-1]: if dpV[i] == 0: continue dpV[i+v] += dpV[i] dpV[i+v] %= mod for r in R: for i in range(M)[::-1]: if dpR[i] == 0: continue dpR[i+r] += dpR[i] dpR[i+r] %= mod cumR = [0]*M for i in range(M): cumR[i] = cumR[i-1]+dpR[i] cumR[i] %= mod ans = 0 for i in range(1,M): if dpV[i] == 0: continue r = i//a l = (i+b-1)//b if r == 0: continue count = cumR[r]-cumR[max(l-1,0)] ans += dpV[i]*count%mod ans %= mod print(ans)