import sys from collections import Counter from operator import add readline = sys.stdin.readline MOD = 10**9+7 class Segtree: def __init__(self, A, intv, initialize = True, segf = max): self.N = len(A) self.N0 = 2**(self.N-1).bit_length() self.intv = intv self.segf = segf if initialize: self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N) for i in range(self.N0-1, 0, -1): self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) else: self.data = [intv]*(2*self.N0) def update(self, k, x): k += self.N0 self.data[k] = x while k > 0 : k = k >> 1 self.data[k] = self.segf(self.data[2*k], self.data[2*k+1]) def query(self, l, r): L, R = l+self.N0, r+self.N0 s = self.intv while L < R: if R & 1: R -= 1 s = self.segf(s, self.data[R]) if L & 1: s = self.segf(s, self.data[L]) L += 1 L >>= 1 R >>= 1 return s def binsearch(self, l, r, check, reverse = False): L, R = l+self.N0, r+self.N0 SL, SR = [], [] while L < R: if R & 1: R -= 1 SR.append(R) if L & 1: SL.append(L) L += 1 L >>= 1 R >>= 1 if reverse: for idx in (SR + SL[::-1]): if check(self.data[idx]): break else: return -1 while idx < self.N0: if check(self.data[2*idx+1]): idx = 2*idx + 1 else: idx = 2*idx return idx - self.N0 else: for idx in (SL + SR[::-1]): if check(self.data[idx]): break else: return -1 while idx < self.N0: if check(self.data[2*idx]): idx = 2*idx else: idx = 2*idx + 1 return idx - self.N0 N, M = map(int, readline().split()) V = list(map(int, readline().split())) R = list(map(int, readline().split())) A, B = map(int, readline().split()) limit = 10**5+2 tablev = Counter() tabler = Counter() tablev[0] = 1 tabler[0] = 1 for v in V: for k, val in tablev.copy().items(): tablev[v+k] += val for r in R: for k, val in tabler.copy().items(): tabler[r+k] += val tablev[0] = 0 tabler[0] = 0 TV = [0]*limit for i in range(limit): TV[i] = tablev[i] ans = 0 T = Segtree(TV, 0, initialize = True, segf = add) for k, v in tabler.items(): left, right = k*A, k*B left = min(left, limit) right = min(right, limit) + 1 ans = (ans + v*T.query(left, right))%MOD print(ans)