""" 作れる抵抗を全列挙 & 作れる電圧を全列挙 累積和でその範囲にいくつあるか調べる かな """ import bisect mod = 10**9+7 N,M = map(int,input().split()) V = list(map(int,input().split())) R = list(map(int,input().split())) A,B = map(int,input().split()) Vdic = {} Vdic[0] = 1 vs = [0] for i in range(N): nv = V[i] pool = [] for j in Vdic: pool.append( [j+nv , Vdic[j] ]) for x in pool: if x[0] not in Vdic: Vdic[x[0]] = 0 vs.append(x[0]) Vdic[x[0]] += x[1] Vdic[x[0]] %= mod vs.append(-1) vs.sort() os = [0] for i in range(1,len(vs)): os.append(os[-1] + Vdic[vs[i]]) if vs[i] == 0: os[-1] = 0 Rdic = {} Rdic[0] = 1 rs = [0] for i in range(M): nr = R[i] pool = [] for j in Rdic: pool.append( [j+nr , Rdic[j] ]) for x in pool: if x[0] not in Rdic: Rdic[x[0]] = 0 rs.append(x[0]) Rdic[x[0]] += x[1] Rdic[x[0]] %= mod ans = 0 for r in Rdic: if r <= 0: continue rlim = r*B llim = r*A lind = bisect.bisect_left(vs,llim) - 1 rind = bisect.bisect_right(vs,rlim) - 1 #print (r,Rdic[r],lind,rind) ans += Rdic[r] * (os[rind] - os[lind]) % mod #print (vs,rs) #print (os) print (ans)