#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 = """3 3 # 2 3 4 # 10 23 26 # 1 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)] dpV[0] = 1 dpV[V[0]] = 1 for i in range(0, N-1): dpV1 = [0 for _ in range(SumV+1)] for v in range(SumV+1): if dpV[v] > 0: dpV1[v] += dpV[v] dpV1[v+V[i+1]] += dpV[v] dpV = dpV1 SumR = sum(R) dpR = [0 for _ in range(SumR+1)] dpR[0] = 1 dpR[R[0]] = 1 for i in range(0, M-1): dpR1 = [0 for _ in range(SumR+1)] for r in range(SumR+1): if dpR[r] > 0: dpR1[r] += dpR[r] dpR1[r+R[i+1]] += dpR[r] dpR = dpR1 SV = [0 for _ in range(SumV+1)] SV[0] = dpV[0] for v in range(1, SumV+1): SV[v] = SV[v-1] + dpV[v] n = 0 for r in range(1, SumR+1): v1 = max(r*A, 1) v2 = min(r*B, SumV) if v1 <= v2: n += dpR[r] * (SV[v2] - SV[v1-1]) print(n % MOD) if __name__ == '__main__': main()