import sys import pypyjit import itertools import heapq import math from collections import deque, defaultdict import bisect input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) pypyjit.set_param('max_unroll_recursion=-1') def index_lt(a, x): 'return largest index s.t. A[i] < x or -1 if it does not exist' return bisect.bisect_left(a, x) - 1 def index_le(a, x): 'return largest index s.t. A[i] <= x or -1 if it does not exist' return bisect.bisect_right(a, x) - 1 def index_gt(a, x): 'return smallest index s.t. A[i] > x or len(a) if it does not exist' return bisect.bisect_right(a, x) def index_ge(a, x): 'return smallest index s.t. A[i] >= x or len(a) if it does not exist' return bisect.bisect_left(a, x) 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 L = 10 ** 5 dpv = [0] * (L + 1) dpv[0] = 1 for v in V: for j in range(L, 0, -1): if j - v < 0: break dpv[j] += dpv[j - v] dpv[j] %= mod for i in range(L): dpv[i + 1] += dpv[i] dpv[i + 1] %= mod dpr = [0] * (L + 1) dpr[0] = 1 for r in R: for j in range(L, 0, -1): if j - r < 0: break dpr[j] += dpr[j - r] dpr[j] %= mod ans = 0 for i in range(1, L + 1): l = min(A * i, L) r = min(B * i, L) ans += dpr[i] * (dpv[r] - dpv[l - 1]) % mod ans %= mod print(ans)