MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) from bisect import bisect_left,bisect_right def main(): n,m = map(int,input().split()) Volt = list(map(int,input().split())) Regist = list(map(int,input().split())) a,b = map(int,input().split()) MAX = 100000 dp1 = [1] + [0] * MAX for v in Volt: for j in range(MAX,0,-1): dp1[j] = dp1[j] if j - v >= 0: dp1[j] += dp1[j - v] dp1[j] %= MOD for i in range(1,MAX + 1): dp1[i] += dp1[i - 1] dp1[i] %= MOD dp2 = [1] + [0] * MAX for r in Regist: for j in range(MAX,0,-1): dp2[j] = dp2[j] if j - r >= 0: dp2[j] += dp2[j - r] dp2[j] %= MOD ans = 0 for r in range(1,MAX + 1): if b*r <= MAX: ans += (dp1[b*r] - dp1[a*r - 1])*dp2[r] elif a*r - 1 <= MAX: ans += (dp1[-1] - dp1[a*r - 1])*dp2[r] ans %= MOD print(ans) if __name__ == '__main__': main()