use std::{collections::BTreeMap, collections::BTreeSet, ops::AddAssign, ops::Neg, ops::RangeInclusive, rc::Rc}; use std::{ops::Add, ops::Sub, ops::Mul, ops::Div, collections::HashMap, collections::HashSet}; use std::cmp::Reverse; use std::collections::{VecDeque, BinaryHeap}; use std::str::FromStr; use std::fmt::Display; use std::cmp::max; use std::cmp::min; use std::cmp::Ordering; use std::fmt::Debug; use std::ops::{Index, IndexMut, SubAssign, MulAssign, DivAssign}; use std::hash::{Hash, Hasher}; use std::collections::hash_map::Entry::Vacant; use std::io::BufRead; use std::borrow::Borrow; const PARSE_ERROR: &str = "Can't Parse"; const EOF_ERROR: &str = "No Line"; macro_rules! freeze { ($($id:ident), *) => { $(let $id = $id;)* }; } macro_rules! read_line { () => { { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect(EOF_ERROR); buffer.trim().to_owned() } }; (&mut $buffer: ident) => { { std::io::stdin().read_line(&mut $buffer).expect(EOF_ERROR); $buffer.trim().to_owned() } }; } macro_rules! read { () => { read_line!() }; ([[char]; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!([char])).collect::>() }; ([[$ty:ty]; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!([$ty])).collect::>() }; ([$ty:ty; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!($ty)).collect::>() }; ([$block: block; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!($block)).collect::>() }; ([$($tt: tt)*] ASC) => { { read!(mut vec: [$($tt)*]); vec.sort(); vec } }; ([$($tt: tt)*] DESC) => { { read!(mut vec: [$($tt)*]); vec.sort_by_key(|&v| Reverse(v)); vec } }; ([char]) => { read_line!().chars().collect::>() }; ([String]) => { read_line!().split_whitespace().map(|s| s.to_owned()).collect::>(); }; ([$ty: ty]) => { read_line!().split_whitespace().map(|x| x.parse().ok().expect(PARSE_ERROR)).collect::>() }; ($ty: ty) => { read_line!().parse::<$ty>().ok().expect(PARSE_ERROR) }; ($block: block) => { $block }; ($ident: ident: [$($tt:tt)*]) => { let $ident = read!([$($tt)*]); }; (mut $ident: ident: [$($tt:tt)*]) => { let mut $ident = read!([$($tt)*]); }; ($ident: ident: [$($tt:tt)*] ASC) => { let $ident = read!([$($tt)*] ASC); }; ($ident: ident: [$($tt:tt)*] DESC) => { let $ident = read!([$($tt)*] DESC); }; ($ident: ident: String) => { let $ident = read!(); }; (mut $ident: ident: String) => { let mut $ident = read!(); }; ($($token: tt)*) => { let line = read_line!(); let mut iter = line.split_whitespace().into_iter(); read_from_iter!(iter; $($token)*); }; } macro_rules! read_from_iter { ($iter:expr; mut $ident:ident:$ty:ty, $($rest:tt)*) => { let mut $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); read_from_iter!($iter; $($rest)*); }; ($iter:expr; $ident:ident:$ty:ty, $($rest:tt)*) => { let $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); read_from_iter!($iter; $($rest)*); }; ($iter:expr; mut $ident:ident:$ty:ty) => { let mut $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); }; ($iter:expr; $ident:ident:$ty:ty) => { let $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); }; ($iter: expr; ) => {}; } struct KeyValue { key: K, value: V } impl PartialEq for KeyValue { fn eq(&self, other: &Self) -> bool { self.key.eq(&other.key) } } impl Eq for KeyValue {} impl PartialOrd for KeyValue { fn partial_cmp(&self, other: &Self) -> Option { self.key.partial_cmp(&other.key) } } impl Ord for KeyValue { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.key.partial_cmp(&other.key).ok_or("Can't Compare").unwrap() } } fn sorted(mut vec: Vec) -> Vec { vec.sort(); vec } #[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] struct OrdF64(f64); impl Ord for OrdF64 { fn cmp(&self, other: &Self) -> Ordering { self.0.partial_cmp(&other.0).unwrap() } } impl Eq for OrdF64 {} fn main() { read!(n: usize, k: usize, x: usize, y: usize); read!(values: [usize]); const MOD: i64 = 9982443353; let mut count = vec![0; 1 << 10]; for v in values { count[v] += 1; } let mut memo = vec![vec![0i64; 1 << 10]; n + 1]; memo[0][0] = 1; for i in 1 ..= n { for x in 0..1024 { for y in 0..1024 { memo[i][x] += memo[i - 1][x ^ y] * count[y] % MOD; if i >= 3 { memo[i][x] += memo[i - 3][x ^ y] * count[y] % MOD; } } if i >= 2 { memo[i][x] = (memo[i][x] - memo[i - 2][x] * (k as i64) % MOD + MOD) % MOD } } } let mut result = 0; for i in x ..= min(y, 1023) { result += memo[n][i]; } println!("{}", result % MOD); }