import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int mod = 1000000007; int n = sc.nextInt(); int m = sc.nextInt(); int[] vArr = new int[n]; int[] rArr = new int[m]; for(int i = 0; i < n; i++) vArr[i] = sc.nextInt(); for(int i = 0; i < m; i++) rArr[i] = sc.nextInt(); int a = sc.nextInt(); int b = sc.nextInt(); int[] dpV = new int[101010]; dpV[0] = 1; int[] dpR = new int[101010]; dpR[0] = 1; for(int i = 0; i < n; i++) for(int j = dpV.length - 1; j > 0; j--) { if(j - vArr[i] < 0) continue; dpV[j] += dpV[j - vArr[i]]; } for(int i = 0; i < m; i++) for(int j = dpR.length - 1; j > 0; j--) { if(j - rArr[i] < 0) continue; dpR[j] += dpR[j - rArr[i]]; } for(int i = 1; i < dpV.length; i++) dpV[i] = (dpV[i] + dpV[i-1]) % mod; long cnt = 0L; for(int r = 1; r < dpR.length; r++) { if(dpR[r] == 0) continue; int leftV = a * r; int rightV = b * r; if(leftV > dpV.length - 1) continue; rightV = Math.min(rightV, dpV.length - 1); cnt = cnt + (long)dpR[r] * (dpV[rightV] - dpV[leftV - 1]) % mod; } System.out.println(cnt); } }