import sys input = sys.stdin.readline from collections import * 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 dp1 = [[0]*(10**5+100) for _ in range(N+1)] dp2 = [[0]*(10**5+100) for _ in range(M+1)] dp1[0][0] = 1 dp2[0][0] = 1 for i in range(N): for j in range(10**5+100): dp1[i+1][j] += dp1[i][j] dp1[i+1][j] %= MOD if j+V[i]<10**5+100: dp1[i+1][j+V[i]] += dp1[i][j] dp1[i+1][j+V[i]] %= MOD acc = [0] for i in range(10**5+100): acc.append((acc[-1]+dp1[N][i])%MOD) for i in range(M): for j in range(10**5+100): dp2[i+1][j] += dp2[i][j] dp2[i+1][j] %= MOD if j+R[i]<10**5+100: dp2[i+1][j+R[i]] += dp2[i][j] dp2[i+1][j+R[i]] %= MOD ans = 0 for i in range(1, 10**5+100): if i*A<10**5+100 and i*B<10**5+100: ans += dp2[M][i]*(acc[i*B+1]-acc[i*A]) ans %= MOD print(ans)