#yuki1043 mod=10**9+7 mab=10**5+1 n,m=map(int,input().split()) v=list(map(int,input().split())) r=list(map(int,input().split())) a,b=map(int,input().split()) dpv=[[0]*mab for i in range(n+1)] dpv[0][0]=1 for i in range(n): for j in range(mab): if j>=v[i]: dpv[i+1][j]=(dpv[i][j-v[i]]+dpv[i][j])%mod else: dpv[i+1][j]=dpv[i][j] dpr=[[0]*mab for i in range(m+1)] dpr[0][0]=1 for i in range(m): for j in range(mab): if j>=r[i]: dpr[i+1][j]=(dpr[i][j-r[i]]+dpr[i][j])%mod else: dpr[i+1][j]=dpr[i][j] sv=[0]*mab for i in range(mab-1): sv[i+1]=(sv[i]+dpv[n][i])%mod res=0 for i in range(1,mab): l=a*i r=min(mab-1,b*i+1) if l>=mab: break res=(res+(sv[r]-sv[l])*dpr[m][i])%mod print(res)