N, M = map(int, input().split()) V = sorted(map(int, input().split())) R = sorted(map(int, input().split())) A, B = map(int, input().split()) mod = 10**9 + 7 V_max, R_max = sum(V), sum(R) dp_v = [1] + [0]*V_max subt = 0 for v in V: for i in range(subt, -1, -1): dp_v[i+v] += dp_v[i] subt += v dp_r = [1] + [0]*R_max subt = 0 for r in R: for i in range(subt, -1, -1): dp_r[i+r] += dp_r[i] subt += r dp_r[0] = 0 for i in range(1, R_max): dp_r[i+1] += dp_r[i] dp_r[i+1] %= mod ans = 0 for v in range(1, V_max+1): dp_v[v] %= mod # (lb, ub] lb, ub = (v+B-1)//B - 1, v//A if ub > R_max: ub = R_max if lb < ub: ans = (ans + dp_v[v] * (dp_r[ub] - dp_r[lb])) % mod print(ans)