use std::io::*; const MOD: usize = 1_000_000_007; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let m: usize = itr.next().unwrap().parse().unwrap(); let v: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let r: Vec = (0..m) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let a: usize = itr.next().unwrap().parse().unwrap(); let b: usize = itr.next().unwrap().parse().unwrap(); let c: usize = v.iter().sum(); let d: usize = r.iter().sum(); let mut dp: Vec = vec![0; c + 1]; dp[0] = 1; for i in 0..n { for j in (0..c - v[i] + 1).rev() { dp[j + v[i]] = (dp[j + v[i]] + dp[j]) % MOD; } } let mut dp2: Vec = vec![0; d + 1]; dp2[0] = 1; for i in 0..m { for j in (0..d - r[i] + 1).rev() { dp2[j + r[i]] = (dp2[j + r[i]] + dp2[j]) % MOD; } } for i in 0..c { dp[i + 1] += dp[i]; dp[i + 1] %= MOD; } // a * sum(r) <= sum(v) <= b * sum(r) let mut ans = 0; for sr in 1..d + 1 { let min = a * sr; let max = b * sr; if min > c { break; } ans = (ans + (dp[std::cmp::min(c, max)] + MOD - dp[min - 1]) % MOD * dp2[sr] % MOD) % MOD; } println!("{}", ans); }