N, M = map(int, input().split()) V = list(map(int, input().split())) R = list(map(int, input().split())) A, B = map(int,input().split()) dp = [[0]*(10**5+1) for _ in range(N)] dp1 = [[0]*(10**5+1) for _ in range(M)] dp[0][0] = 1;dp[0][V[0]] = 1 dp1[0][0] = 1;dp1[0][R[0]] = 1 for i in range(1, N): for j in range(10**5+1): dp[i][j] += dp[i-1][j] if dp[i-1][j] > 0: dp[i][j+V[i]] += dp[i-1][j] for i in range(1, M): for j in range(10**5+1): dp1[i][j] += dp1[i-1][j] if dp1[i-1][j] > 0: dp1[i][j+R[i]] += dp1[i-1][j] from itertools import accumulate VV = list(accumulate(dp[-1])) res = 0 mod = 10**9+7 for i in range(1,len(dp1[-1])): if dp1[-1][i] > 0 and A*dp1[-1][i]<=10**5: res += (VV[min(10**5, B*i)] - VV[A*i-1])*dp1[-1][i] res %= mod print(res)