#region Header #!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools from queue import PriorityQueue import bisect import heapq def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) #endregion # _INPUT = """2 2 # 5 10 # 1 1 # 3 100 # """ # sys.stdin = io.StringIO(_INPUT) MOD = 1000000007 def main(): N, M = map(int, input().split()) V = list(map(int, input().split())) R = list(map(int, input().split())) A, B = map(int, input().split()) SumV = sum(V) dpV = [[0 for _ in range(SumV+1)] for _ in range(N)] dpV[0][0] = 1 dpV[0][V[0]] = 1 for i in range(0, N-1): for v in range(SumV+1): if dpV[i][v] > 0: dpV[i+1][v] += dpV[i][v] dpV[i+1][v+V[i+1]] += dpV[i][v] SumR = sum(R) dpR = [[0 for _ in range(SumR+1)] for _ in range(M)] dpR[0][0] = 1 dpR[0][R[0]] = 1 for i in range(0, M-1): for r in range(SumR+1): if dpR[i][r] > 0: dpR[i+1][r] += dpR[i][r] dpR[i+1][r+R[i+1]] += dpR[i][r] SV = [0 for _ in range(SumV+1)] SV[0] = dpV[N-1][0] for v in range(1, SumV+1): SV[v] = SV[v-1] + dpV[N-1][v] # n = 0 # for r in range(1, SumR+1): # for v in range(max(r*A, 1), min(r*B, SumV)+1): # n += dpR[M-1][r] * dpV[N-1][v] n = 0 for r in range(1, SumR+1): n += dpR[M-1][r] * (SV[min(r*B, SumV)] - SV[max(r*A, 1)-1]) print(n % MOD) if __name__ == '__main__': main()