n,m=map(int,input().split()) *v,=map(int,input().split()) *r,=map(int,input().split()) sr=sum(r) sv=sum(v) a,b=map(int,input().split()) mod=10**9+7 dpv=[[0]*(100*1000+1) for _ in range(n+1)] dpv[0][0]=1 dpr=[[0]*(100*1000+1) for _ in range(m+1)] dpr[0][0]=1 for i in range(1,n+1): dpv[i][0]=1 for j in range(100*1000+1): dpv[i][j]=dpv[i-1][j] if 0<=j-v[i-1]<=100*1000: dpv[i][j]+=dpv[i-1][j-v[i-1]] dpv[i][j]%=mod for i in range(1,m+1): dpr[i][0]=1 for j in range(100*1000+1): dpr[i][j]=dpr[i-1][j] if 0<=j-r[i-1]<=100*1000: dpr[i][j]+=dpr[i-1][j-r[i-1]] dpr[i][j]%=mod dpv=dpv[-1] dpv[0]=0 from itertools import accumulate dpvacc=list(accumulate(dpv)) dpr=dpr[-1] ans=0 for R in range(1, 100*1000+1): ans+=(dpr[R]*(dpvacc[min(100*1000,b*R)]-dpvacc[min(a*R,100*1000)-1]))%mod ans%=mod print(ans)