use std::io::Read; fn main() { const DIVIDER: usize = 1_000_000_007; let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let dlrk: Vec = all_data.trim().split('\n').next().unwrap().trim().split_whitespace() .map(|s| s.parse().unwrap()) .collect(); let d: usize = dlrk[0]; let l: usize = dlrk[1]; let r: usize = dlrk[2]; let k: usize = dlrk[3]; let mut l_count = 0; let mut r_count = 0; for i in 1..=d { if l < 2i32.pow(i as u32) as usize { l_count = i; break; } } for i in 1..=d { if r < 2i32.pow(i as u32) as usize { r_count = i; break; } } if l_count < r_count { if (r_count - l_count + k) % 2 == 1 { println!("{}", 0); } else if r_count - l_count > k || r_count + l_count - 2 < k { println!("{}", 0); } else { let mut result: usize = 1; for depth in 1..=d { if depth == r_count { for i in 1..(2i32.pow(depth as u32 -1)) { result *= i as usize; result %= DIVIDER; } if r_count - l_count == k { result *= 2i32.pow(r_count as u32 - l_count as u32) as usize; } else { result *= 2i32.pow(r_count as u32 - l_count as u32 + (k as u32 + l_count as u32 - r_count as u32) / 2 - 1u32) as usize; } result %= DIVIDER; } else { for i in 1..=(2i32.pow(depth as u32 -1)) { result *= i as usize; result %= DIVIDER; } } } println!("{}", result); } } else { if k < 2 || k % 2 != 0 || r_count + l_count - 2 < k { println!("{}", 0); } else { let mut result: usize = 1; for depth in 1..=d { if depth == r_count { for i in 1..(2i32.pow(depth as u32 -1) - 1) { result *= i as usize; result %= DIVIDER; } result *= 2i32.pow(depth as u32 -1) as usize; result %= DIVIDER; result *= 2i32.pow((k as u32) / 2 - 1) as usize; result %= DIVIDER; } else { for i in 1..=(2i32.pow(depth as u32 -1)) { result *= i as usize; result %= DIVIDER; } } } println!("{}", result); } } }