import java.util.*; public class Main { static final int MAX = 100 * 1000 + 1; 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(); long[] volts = new long[MAX]; volts[0] = 1; for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = 1000 * i; j >= 0; j--) { volts[j + x] += volts[j]; volts[j + x] %= MOD; } } long[] sums = new long[MAX]; for (int i = 1; i < MAX; i++) { sums[i] += sums[i - 1] + volts[i]; sums[i] %= MOD; } long[] resists = new long[MAX]; resists[0] = 1; for (int i = 0; i < m; i++) { int x = sc.nextInt(); for (int j = 1000 * i; j >= 0; j--) { resists[j + x] += resists[j]; resists[j + x] %= MOD; } } int a = sc.nextInt(); int b = sc.nextInt(); long ans = 0; for (int i = 1; i * a < MAX; i++) { ans += (sums[Math.min(MAX - 1, i * b)] - sums[i * a - 1] + MOD) % MOD * resists[i] % MOD; ans %= MOD; } System.out.println(ans); } }