import sys from itertools import accumulate sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N,M = MI() V,R = [0]+LI(),[0]+LI() A,B = MI() mod = 10**9+7 V_count = [[0]*100001 for _ in range(N+1)] V_count[0][0] = 1 for i in range(1,N+1): v = V[i] for j in range(100001): V_count[i][j] = V_count[i-1][j] if j >= v: V_count[i][j] += V_count[i-1][j-v] V_count[i][j] %= mod A_V_count = list(accumulate(V_count[-1])) R_count = [[0]*100001 for _ in range(M+1)] R_count[0][0] = 1 for i in range(1,M+1): r = R[i] for j in range(100001): R_count[i][j] = R_count[i-1][j] if j >= r: R_count[i][j] += R_count[i-1][j-r] R_count[i][j] %= mod ans = 0 for i in range(1,100001): if A*i > 100000: break ans += R_count[-1][i]*(A_V_count[min(100000,B*i)]-A_V_count[A*i-1]) ans %= mod print(ans)