fn main() { let stdin = std::io::read_to_string(std::io::stdin()).unwrap(); let mut stdin = stdin.split_whitespace(); let t: usize = stdin.next().unwrap().parse().unwrap(); let testcases = (0..t) .map(|_| { let n: usize = stdin.next().unwrap().parse().unwrap(); let k: u32 = stdin.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); (k, a) }) .collect::>(); println!("{}", output(solve(testcases))); } fn solve(testcases: Vec<(u32, Vec)>) -> Vec { testcases .into_iter() .map(|(k, mut a)| { let min_a = *a.iter().min().unwrap(); let pos = a.iter().position(|&a| a == min_a).unwrap(); a[pos] -= k; a.into_iter().map(|a| a as u64).product() }) .collect() } fn output(ans: Vec) -> String { ans.into_iter() .map(|x| x.to_string()) .collect::>() .join("\n") }