import java.util.*; public class Main { static final int MOD = 1000000007; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); HashMap vMap = new HashMap<>(); vMap.put(0, 1); for (int i = 0; i < n; i++) { int x = sc.nextInt(); HashMap tmp = new HashMap<>(); for (Map.Entry entry : vMap.entrySet()) { tmp.put(entry.getKey() + x, entry.getValue()); } for (Map.Entry entry : tmp.entrySet()) { if (vMap.containsKey(entry.getKey())) { vMap.put(entry.getKey(), (vMap.get(entry.getKey()) + entry.getValue()) % MOD); } else { vMap.put(entry.getKey(), entry.getValue()); } } } HashMap rMap = new HashMap<>(); rMap.put(0, 1); for (int i = 0; i < m; i++) { int x = sc.nextInt(); HashMap tmp = new HashMap<>(); for (Map.Entry entry : rMap.entrySet()) { tmp.put(entry.getKey() + x, entry.getValue()); } for (Map.Entry entry : tmp.entrySet()) { if (rMap.containsKey(entry.getKey())) { rMap.put(entry.getKey(), (rMap.get(entry.getKey()) + entry.getValue()) % MOD); } else { rMap.put(entry.getKey(), entry.getValue()); } } } int left = sc.nextInt(); int right = sc.nextInt(); int[] vsums = new int[n * 1000 + 1]; for (int i = 1; i < vsums.length; i++) { vsums[i] = vsums[i - 1]; if (vMap.containsKey(i)) { vsums[i] += vMap.get(i); vsums[i] %= MOD; } } long total = 0; for (Map.Entry entry : rMap.entrySet()) { int key = entry.getKey(); if ((long)key * left >= vsums.length) { continue; } if (key == 0) { continue; } int min = key * left - 1; int max = (int)Math.min((long)key * right, vsums.length - 1); total += (long)(vsums[max] - vsums[min] + MOD) * entry.getValue(); total %= MOD; } System.out.println(total); } }