MOD = 998244353 def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]); ptr +=1 K = int(input[ptr]); ptr +=1 X = int(input[ptr]); ptr +=1 Y = int(input[ptr]); ptr +=1 A = list(map(int, input[ptr:ptr+K])) ptr += K # Remove duplicates and ensure order (though problem states A has unique elements) A = list(dict.fromkeys(A)) K = len(A) # Precompute allowed transitions: for each element index, list of allowed next indices allowed = [[] for _ in range(K)] for i in range(K): for j in range(K): if i != j: allowed[i].append(j) # Determine the maximum possible XOR value max_xor = 0 if N > 0: max_a = max(A) max_xor = max_a # For N elements, the maximum XOR can be up to (max_a) * (some factor), but in practice, we use the maximum possible based on problem constraints # For the original problem constraints, A_i < 1024, so max_xor is 1023 # For other cases, this might need adjustment, but here we proceed with 1024 as per original constraints max_xor = 1023 # Assuming original problem's constraints # Initialize DP: prev_dp[i][x] is the count ending with A[i] with XOR x prev_dp = [[0] * (max_xor + 1) for _ in range(K)] for i in range(K): a = A[i] prev_dp[i][a] = 1 # First element is a for _ in range(N - 1): next_dp = [[0] * (max_xor + 1) for _ in range(K)] for i in range(K): for x in range(max_xor + 1): if prev_dp[i][x] == 0: continue cnt = prev_dp[i][x] for j in allowed[i]: q = A[j] new_x = x ^ q if new_x > max_xor: continue # Skip if beyond the considered range next_dp[j][new_x] = (next_dp[j][new_x] + cnt) % MOD prev_dp = next_dp total = 0 for i in range(K): for x in range(X, Y + 1): if x <= max_xor: total = (total + prev_dp[i][x]) % MOD print(total % MOD) if __name__ == "__main__": main()