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=1000000007 from collections import Counter C=Counter() C[0]=1 for v in V: NC=Counter() for c in C: NC[c]=(NC[c]+C[c])%mod NC[c+v]=(NC[c+v]+C[c])%mod C=NC C2=Counter() C2[0]=1 for r in R: NC2=Counter() for c2 in C2: NC2[c2]=(NC2[c2]+C2[c2])%mod NC2[c2+r]=(NC2[c2+r]+C2[c2])%mod C2=NC2 del(C[0]) del(C2[0]) ANS=0 for c in C: for c2 in C2: if A*c2<=c<=B*c2: ANS=(ANS+C[c]*C2[c2])%mod print(ANS)