import sys import io, os input = sys.stdin.buffer.readline 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 = 10**9+7 M = 10**5+50 SV = [0]*M SR = [0]*M SV[0] = 1 for v in V: temp = [0]*M for i in range(M): temp[i] = SV[i] for i in range(M): if i+v < M: temp[i+v] += SV[i] temp[i+v] %= mod SV = temp SR[0] = 1 for r in R: temp = [0]*M for i in range(M): temp[i] = SR[i] for i in range(M): if i+r < M: temp[i+r] += SR[i] temp[i+r] %= mod SR = temp from itertools import accumulate cum = SV cum = list(accumulate(cum)) ans = 0 for i in range(1, M): c = SR[i] l = a*i r = b*i ans += (cum[min(r, M-1)]-cum[min(l-1, M-1)])*c ans %= mod print(ans)