#include using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; template using max_heap = std::priority_queue; template using min_heap = std::priority_queue, std::greater>; constexpr int popcount(const ull v) { return v ? __builtin_popcountll(v) : 0; } constexpr int log2p1(const ull v) { return v ? 64 - __builtin_clzll(v) : 0; } constexpr int lsbp1(const ull v) { return __builtin_ffsll(v); } constexpr int clog(const ull v) { return v ? log2p1(v - 1) : 0; } constexpr ull ceil2(const ull v) { return 1ULL << clog(v); } constexpr ull floor2(const ull v) { return v ? (1ULL << (log2p1(v) - 1)) : 0ULL; } constexpr bool btest(const ull mask, const int ind) { return (mask >> ind) & 1ULL; } template void bset(T& mask, const int ind) { mask |= ((T)1 << ind); } template void breset(T& mask, const int ind) { mask &= ~((T)1 << ind); } template void bflip(T& mask, const int ind) { mask ^= ((T)1 << ind); } template void bset(T& mask, const int ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); } template struct bfft { bfft() = delete; static void fzt(std::vector& a) { const int sz = a.size(); for (int i = 1; i < sz; i <<= 1) { for (int j = 0; j < sz; j++) { if ((j & i) == 0) { a[j | i] += a[j]; } } } } static void fmt(std::vector& a) { const int sz = a.size(); for (int i = 1; i < sz; i <<= 1) { for (int j = 0; j < sz; j++) { if ((j & i) == 0) { a[j | i] -= a[j]; } } } } static void fwt(std::vector& a, const bool rev) { const int sz = a.size(); for (int i = 1; i < sz; i <<= 1) { for (int j = 0; j < sz; j++) { if ((j & i) == 0) { const T x = a[j], y = a[j | i]; a[j] = (rev ? (x + y) / T(2) : x + y), a[j | i] = (rev ? (x - y) / T(2) : x - y); } } } } static std::vector and_convolute(const std::vector& a, const std::vector& b) { const int sz = ceil2(std::max(a.size(), b.size())); std::vector A(sz), B(sz); for (int i = 0; i < a.size(); i++) { A[i] = a[i]; } for (int i = 0; i < b.size(); i++) { B[i] = b[i]; } fzt(A), fzt(B); for (int i = 0; i < sz; i++) { A[i] *= B[i]; } return fmt(A), A; } static std::vector or_convolute(const std::vector& a, const std::vector& b) { const int sz = ceil2(std::max(a.size(), b.size())); const int mask = (1 << sz) - 1; std::vector A(sz), B(sz); for (int i = 0; i < a.size(); i++) { A[i] = a[mask ^ i]; } for (int i = 0; i < b.size(); i++) { B[i] = b[mask ^ i]; } auto C = and_convolute(A, B); for (int i = 0; i < sz - i; i++) { std::swap(C[i], C[mask ^ i]); } return C; } static std::vector xor_convolute(const std::vector& a, const std::vector& b) { const int sz = ceil2(std::max(a.size(), b.size())); std::vector A(sz), B(sz); for (int i = 0; i < a.size(); i++) { A[i] = a[i]; } for (int i = 0; i < b.size(); i++) { B[i] = b[i]; } fwt(A, false), fwt(B, false); for (int i = 0; i < sz; i++) { A[i] *= B[i]; } return fwt(A, true), A; } }; template class modint { public: modint() : m_val{0} {} modint(const ll v) : m_val{normll(v)} {} modint(const modint& m) = default; modint& operator =(const modint& m) { return m_val = m(), (*this); } modint& operator =(const ll v) { return m_val = normll(v), (*this); } modint operator+() const { return *this; } modint operator-() const { return modint{0} - (*this); } modint& operator+=(const modint& m) { return m_val = norm(m_val + m()), *this; } modint& operator-=(const modint& m) { return m_val = norm(m_val + mod - m()), *this; } modint& operator*=(const modint& m) { return m_val = normll((ll)m_val * (ll)m() % (ll)mod), *this; } modint& operator/=(const modint& m) { return *this *= m.inv(); } modint& operator+=(const ll val) { return *this += modint{val}; } modint& operator-=(const ll val) { return *this -= modint{val}; } modint& operator*=(const ll val) { return *this *= modint{val}; } modint& operator/=(const ll val) { return *this /= modint{val}; } modint operator+(const modint& m) const { return modint{*this} += m; } modint operator-(const modint& m) const { return modint{*this} -= m; } modint operator*(const modint& m) const { return modint{*this} *= m; } modint operator/(const modint& m) const { return modint{*this} /= m; } modint operator+(const ll v) const { return *this + modint{v}; } modint operator-(const ll v) const { return *this - modint{v}; } modint operator*(const ll v) const { return *this * modint{v}; } modint operator/(const ll v) const { return *this / modint{v}; } bool operator==(const modint& m) const { return m_val == m(); } bool operator!=(const modint& m) const { return not(*this == m); } friend modint operator+(const ll v, const modint& m) { return modint{v} + m; } friend modint operator-(const ll v, const modint& m) { return modint{v} - m; } friend modint operator*(const ll v, const modint& m) { return modint{v} * m; } friend modint operator/(const ll v, const modint& m) { return modint{v} / m; } friend std::istream& operator>>(std::istream& is, modint& m) { ll v; return is >> v, m = v, is; } friend std::ostream& operator<<(std::ostream& os, const modint& m) { return os << m(); } uint operator()() const { return m_val; } modint pow(ull n) const { modint ans = 1; for (modint x = *this; n > 0; n >>= 1, x *= x) { if (n & 1ULL) { ans *= x; } } return ans; } modint inv() const { return m_val <= 2000000 ? sinv(m_val) : pow(mod - 2); } static modint fact(const uint n) { static std::vector fs{1, 1}; for (uint i = (uint)fs.size(); i <= n; i++) { fs.push_back(fs.back() * i); } return fs[n]; } static modint ifact(const uint n) { static std::vector ifs{1, 1}; for (uint i = (uint)ifs.size(); i <= n; i++) { ifs.push_back(ifs.back() * sinv(i)); } return ifs[n]; } static modint perm(const int n, const int k) { return k > n or k < 0 ? modint{0} : fact(n) * ifact(n - k); } static modint comb(const int n, const int k) { return k > n or k < 0 ? modint{0} : fact(n) * ifact(n - k) * ifact(k); } private: static constexpr uint norm(const uint x) { return x < mod ? x : x - mod; } static constexpr uint normll(const ll x) { return norm(uint(x % (ll)mod + (ll)mod)); } static modint sinv(const uint n) { static std::vector is{1, 1}; for (uint i = (uint)is.size(); i <= n; i++) { is.push_back(-is[mod % i] * (mod / i)); } return is[n]; } uint m_val; }; template bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); } template bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); } template constexpr T inf_v = std::numeric_limits::max() / 4; template constexpr Real pi_v = Real{3.141592653589793238462643383279502884}; template constexpr T TEN(const int n) { return n == 0 ? T{1} : TEN(n - 1) * T{10}; } template struct fix : F { fix(F&& f) : F{std::forward(f)} {} template auto operator()(Args&&... args) const { return F::operator()(*this, std::forward(args)...); } }; template auto nd_array(int const (&szs)[n], const T x = T{}) { if constexpr (i == n) { return x; } else { return std::vector(szs[i], nd_array(szs, x)); } } template std::ostream& operator<<(std::ostream& os, const std::array& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::deque& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::map& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::multimap& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::multiset& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::pair& v) { return (os << "<" << v.first << "," << v.second << ">"); } template std::ostream& operator<<(std::ostream& os, const std::priority_queue& v) { auto q = v; os << "["; while (not q.empty()) { os << q.top() << ",", q.pop(); } return os << "]\n"; } template std::ostream& operator<<(std::ostream& os, const std::queue& v) { auto q = v; os << "["; while (not q.empty()) { os << q.front() << ",", q.pop(); } return os << "]\n"; } template std::ostream& operator<<(std::ostream& os, const std::set& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::stack& v) { auto q = v; os << "["; while (not q.empty()) { os << q.top() << ",", q.pop(); } return os << "]\n"; } template std::ostream& print(std::ostream& os, const TupType& _tup, std::index_sequence) { return os << "(", (..., (os << (I == 0 ? "" : ", ") << std::get(_tup))), os << ")\n"; } template std::ostream& operator<<(std::ostream& os, const std::tuple& _tup) { return print(os, _tup, std::make_index_sequence()); } template std::ostream& operator<<(std::ostream& os, const std::unordered_map& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_multimap& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_multiset& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_set& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::vector& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } class printer { public: printer(std::ostream& os_ = std::cout) : m_os{os_} { m_os << std::fixed << std::setprecision(15); } template int ln(const Args&... args) { return dump(args...), m_os << '\n', 0; } template int el(const Args&... args) { return dump(args...), m_os << std::endl, 0; } private: template void dump(const T& v) { m_os << v; } template void dump(const std::vector& vs) { for (int i = 0; i < (int)vs.size(); i++) { m_os << (i ? " " : ""), dump(vs[i]); } } template void dump(const std::vector>& vss) { for (int i = 0; i < (int)vss.size(); i++) { m_os << (0 <= i or i + 1 < (int)vss.size() ? "\n" : ""), dump(vss[i]); } } template int dump(const T& v, const Args&... args) { return dump(v), m_os << ' ', dump(args...), 0; } std::ostream& m_os; }; printer out; class scanner { public: scanner(std::istream& is_ = std::cin) : m_is{is_} { m_is.tie(nullptr), std::ios::sync_with_stdio(false); } template T val() { T v; return m_is >> v, v; } template T val(const T offset) { return val() - offset; } template std::vector vec(const int n) { return make_v(n, [this]() { return val(); }); } template std::vector vec(const int n, const T offset) { return make_v(n, [this, offset]() { return val(offset); }); } template std::vector> vvec(const int n0, const int n1) { return make_v>(n0, [this, n1]() { return vec(n1); }); } template std::vector> vvec(const int n0, const int n1, const T offset) { return make_v>(n0, [this, n1, offset]() { return vec(n1, offset); }); } template auto tup() { return std::tuple...>{val()...}; } template auto tup(const Args&... offsets) { return std::tuple...>{val(offsets)...}; } private: template std::vector make_v(const int n, F f) { std::vector ans; for (int i = 0; i < n; i++) { ans.push_back(f()); } return ans; } std::istream& m_is; }; scanner in; template void HogeHogeSansuu(T x) { std::cerr << x; } template void HogeHogeSansuu(T x, Args... args) { std::cerr << x << ",", HogeHogeSansuu(args...); } int main() { static constexpr uint mod = 998244353; using mint = modint; const auto [N, K, X, Y] = in.tup(); assert(2 <= N and N <= 40); assert(N % 2 == 0); assert(0 <= X and X <= Y and Y <= TEN(9)); { ull prod = 1; for (int i = 0; i < N; i++) { prod *= (ull)K; } assert(prod <= 2ULL * TEN(15)); } const auto as = in.vec(K); const int H = N / 2; constexpr int A = 1024; for (const int a : as) { assert(0 <= a and a < A); } if (N == 2) { assert(false); } auto total = nd_array({A}, 0); auto dp = nd_array({A, A}, 0); for (int i = 0; i < K; i++) { fix([&](auto self, int n, int x, int y) -> void { if (n == H) { total[x] += 1; dp[as[i]][x] += 1; } else { for (int k = 0; k < K; k++) { if (as[k] == y) { continue; } const int nx = x ^ as[k]; self(n + 1, nx, as[k]); } } })(1, as[i], as[i]); } total = bfft::xor_convolute(total, total); for (int a = 0; a < A; a++) { dp[a] = bfft::xor_convolute(dp[a], dp[a]); for (int x = 0; x < A; x++) { total[x] -= dp[a][x]; } } mint ans = 0; for (int x = 0; x < A; x++) { if (X <= x and x <= Y) { ans += total[x]; } } out.ln(ans); return 0; }