N,M = map(int,input().split()) lsV = list(map(int,input().split())) lsR = list(map(int,input().split())) A,B = map(int,input().split()) mod = 10**9+7 dpV = [0]*(10**5+2) dpV[0] = 1 for j in range(N): dpV2 = dpV[:] for i in range(10**5+1): if i + lsV[j] <= 10**5: dpV2[i + lsV[j]] += dpV[i] dpV2[i + lsV[j]] %= mod dpV = dpV2 dpR = [0]*(10**5+1) dpR[0] = 1 for j in range(M): dpR2 = dpR[:] for i in range(10**5+1): if i + lsR[j] <= 10**5: dpR2[i + lsR[j]] += dpR[i] dpR2[i + lsR[j]] %= mod dpR = dpR2 for i in range(1,10**5+2): dpV[i] += dpV[i-1] dpV[i] %= mod ans = 0 for j in range(1,10**5+1): ans += dpR[j]*(dpV[min(10**5+1,B*j)]-dpV[min(10**5+1,A*j-1)]) ans %= mod print(ans)