mod=10**9+7 n,m=map(int,input().split()) arr1=list(map(int,input().split())) arr2=list(map(int,input().split())) a,b=map(int,input().split()) dp1=[0]*(1000*n+1) dp1[0]=1 dp2=[0]*(1000*m+1) dp2[0]=1 for i in range(n): for j in range(1000*n,arr1[i]-1,-1): dp1[j]+=dp1[j-arr1[i]] for i in range(1,1000*n+1): dp1[i]+=dp1[i-1] for i in range(n): for j in range(1000*n,arr2[i]-1,-1): dp2[j]+=dp2[j-arr2[i]] ans=0 for i in range(1,1000*m+1): ans+=dp2[i]*(dp1[min(b*i,1000*n)]-dp1[min(a*i-1,1000*n)]) ans%=mod print(ans)