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..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let a: usize = itr.next().unwrap().parse().unwrap(); let b: usize = itr.next().unwrap().parse().unwrap(); // 小問題1: 電圧の和がxになるものの組み合わせの数 let mut dp: Vec = vec![0; 110000]; dp[0] = 1; for i in 0..n { for j in (0..101010).rev() { dp[j + v[i]] = (dp[j + v[i]] + dp[j]) % MOD; } } let mut dp2: Vec = vec![0; 110000]; dp2[0] = 1; for i in 0..m { for j in (0..101010).rev() { dp2[j + r[i]] = (dp2[j + r[i]] + dp2[j]) % MOD; } } for i in 0..101010 { dp[i + 1] += dp[i]; dp[i + 1] %= MOD; } // a * sum(r) <= sum(v) <= b * sum(r) let mut ans = 0; for sr in 0..101010 { let min = a * sr; let max = b * sr; if max > 101010 { continue; } if min == 0 { ans = (ans + dp2[sr] * dp[max] % MOD) % MOD; } else { ans = (ans + dp2[sr] * (dp[max] + MOD - dp[min - 1]) % MOD) % MOD; } } println!("{}", ans - 1); }