#include #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long long #define rep(i, m, n) for (ll i = m; i < n; i++) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define mod 998244353 int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll N, K, X, Y; cin >> N >> K >> X >> Y; assert(powl(K,N) <= 2 *powl(10,15)); vector> dp(N + 2, vector(1024, 0)); vector A(K); rep(i, 0, K) cin >> A[i]; Sort(A), UE(A); K = A.size(); dp[0][0] = 1; rep(i, 0, K) dp[1][A[i]]++; rep(i, 0, 1024) { rep(l, 0, K) dp[2][i] += dp[1][i ^ A[l]]; dp[2][i] -= dp[0][i] * K; } rep(i, 3, N + 1) { rep(j, 0, 1024) { rep(l, 0, K) dp[i][j] = (dp[i][j] + dp[i - 1][j ^ A[l]]) % mod; dp[i][j] = (dp[i][j] - dp[i - 2][j] * (K - 1) + mod) % mod; } } ll res=0; rep(i, 0, 1024) if(X <= i & i <= Y) res = res + dp[N][i]; cout << res % mod << endl; }