import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); int[] v = new int[n]; for (int i = 0; i < n; i++) { v[i] = Integer.parseInt(sa[i]); } sa = br.readLine().split(" "); int[] r = new int[m]; for (int i = 0; i < m; i++) { r[i] = Integer.parseInt(sa[i]); } sa = br.readLine().split(" "); int a = Integer.parseInt(sa[0]); int b = Integer.parseInt(sa[1]); br.close(); int mod = 1000000007; int mx = 100000; long[] dpv = dp(v, n); for (int i = 1; i <= mx; i++) { dpv[i] += dpv[i - 1]; dpv[i] %= mod; } long[] dpr = dp(r, m); long ans = 0; for (int i = 1; i <= mx; i++) { int min = i * a; if (min > mx) { break; } int max = Math.min(i * b, mx); long cv = dpv[max] - dpv[min - 1] + mod; ans += cv * dpr[i]; ans %= mod; } System.out.println(ans); } static long[] dp(int[] v, int n) { int mod = 1000000007; int mx = 100000; long[] dp = new long[mx + 1]; dp[0] = 1; for (int i = 0; i < n; i++) { long[] work = new long[mx + 1]; for (int j = mx - v[i] + 1; j <= mx; j++) { work[j] = dp[j]; } for (int j = mx - v[i]; j >= 0; j--) { work[j + v[i]] += dp[j]; work[j + v[i]] %= mod; work[j] = dp[j]; } dp = work; } return dp; } }