local mod = 1000000007 local mfl = math.floor local mmi, mma = math.min, math.max local function bmul(x, y) local x1, y1 = mfl(x / 31623), mfl(y / 31623) local x0, y0 = x - x1 * 31623, y - y1 * 31623 return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod end local function badd(x, y) return (x + y) % mod end local function bsub(x, y) return x < y and x - y + mod or x - y end local n, m = io.read("*n", "*n") local v, r = {}, {} for i = 1, n do v[i] = io.read("*n") end for i = 1, m do r[i] = io.read("*n") end local a, b = io.read("*n", "*n") local vdp, rdp = {}, {} local lim = 100000 for i = 1, lim do vdp[i], rdp[i] = 0, 0 end for i = 1, n do local vi = v[i] for j = lim - vi, 1, -1 do vdp[j + vi] = badd(vdp[j + vi], vdp[j]) end vdp[vi] = badd(vdp[vi], 1) end for i = 1, m do local ri = r[i] for j = lim - ri, 1, -1 do rdp[j + ri] = badd(rdp[j + ri], rdp[j]) end rdp[ri] = badd(rdp[ri], 1) end local vsum = {} vsum[1] = vdp[1] for i = 2, lim do vsum[i] = badd(vsum[i - 1], vdp[i]) end local ret = 0 for ir = 1, lim do local rr = rdp[ir] local vmin = ir * a local vmax = mmi(lim, ir * b) if vmin <= vmax then local z = vsum[vmax] if 1 < vmin then z = bsub(z, vsum[vmin - 1]) end ret = badd(ret, bmul(z, rr)) end end print(ret)