def Subsum_Count(L): L_sum=sum(L) X=[0]*(L_sum+1) X[0]=1 for x in L: for a in range(L_sum,x-1,-1): X[a]+=X[a-x] X[a]%=Mod return X 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 V_sum=sum(V) X=Subsum_Count(V) R_sum=sum(R) Y=Subsum_Count(R) X_accum=[0]*len(X) X_accum[0]=X[0] for i in range(1,len(X)): X_accum[i]=X_accum[i-1]+X[i] X_accum[i]%=Mod Ans=0 for r in range(1,R_sum+1): left =max(r*A,0) right=min(r*B,V_sum) if left>right: continue if left==0: Ans+=Y[r]*X_accum[right] else: Ans+=Y[r]*(X_accum[right]-X_accum[left-1]) Ans%=Mod print(Ans)