n,m = map(int,input().split()) vi = [int(i) for i in input().split()] ri = [int(i) for i in input().split()] a,b = map(int,input().split()) mod = 10**9+7 dp_vi = [[0 for i in range(sum(vi)+1)] for j in range(n)] dp_ri = [[0 for i in range(sum(ri)+1)] for j in range(m)] dp_vi[0][vi[0]] = 1 #print(dp_vi) for i in range(1,n): #print(i) for j in range(sum(vi)+1): #print(i,j) if j-vi[i] > 0: dp_vi[i][j] = dp_vi[i-1][j-vi[i]] + dp_vi[i-1][j] elif j == vi[i]: dp_vi[i][j] = dp_vi[i-1][j] + 1 else: dp_vi[i][j] = dp_vi[i-1][j] dp_ri[0][ri[0]] = 1 for i in range(1,m): #print(i) for j in range(sum(ri)+1): #print(i,j) if j-ri[i] > 0: dp_ri[i][j] = dp_ri[i-1][j-ri[i]] + dp_ri[i-1][j] elif j == ri[i]: dp_ri[i][j] = dp_ri[i-1][j] + 1 else: dp_ri[i][j] = dp_ri[i-1][j] dp = [0]*(sum(ri)+1) dp[1] = dp_ri[m-1][1] for i in range(1,sum(ri)): dp[i+1] = dp[i] + dp_ri[m-1][i+1] ans = 0 #print(dp_ri) #exit() for i in range(1,sum(vi)+1): #print(i) max_ohm = min(i // a,sum(ri)) #print(st) #print(dp[st]) min_ohm = (i+b-1) // b if max_ohm < min_ohm: continue #print(i,st,ed,dp_vi[n-1][i]) #print(dp[st],dp[ed-1]) ans += (dp[max_ohm]-dp[min_ohm-1])*dp_vi[n-1][i] #print(dp_vi) print(ans)