import collections import itertools 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 DPV = collections.defaultdict(int) DPR = collections.defaultdict(int) DPV[0]=1 DPR[0]=1 for a in V: NDPV = collections.defaultdict(int) for k,v in DPV.items(): NDPV[k+a]=(v+NDPV[k+a])%mod NDPV[k]=(v+NDPV[k])%mod DPV = NDPV for a in R: NDPR = collections.defaultdict(int) for k,v in DPR.items(): NDPR[k+a]=(v+NDPR[k+a])%mod NDPR[k]=(v+NDPR[k])%mod DPR = NDPR RS = [0]*1000*(M+1) for k,v in DPR.items(): RS[k]=v RAC = list(itertools.accumulate(RS)) ans = 0 for k,v in DPV.items(): if k>0: ma = k//A mi = -(-k//B) ans = (ans+(RAC[min(ma,len(RAC)-1)]-RAC[min(mi-1,len(RAC)-1)])*v)%mod print(ans)