luogu#P5387. [Cnoi2019] 人形演舞

[Cnoi2019] 人形演舞

Background

Since the problem setters have all retired, the background has been put off indefinitely.

Problem Description

There is a game between Cirno and Marisa:

First, a sequence VV is given, and all numbers are in [1,m][1, m].

On each turn, a player may choose xVx \in V, y[1,x]y \in [1, x], and require that xy[0,x)x \oplus y \in [0, x), then change xx into xyx \oplus y.

\oplus denotes bitwise XOR.

If a player cannot make a move, then that player is considered to lose.

Assume that both Cirno and Marisa use optimal strategies.

Now Cirno wants to know, when she moves first, what is the number of winning initial sequences modulo 998244353998244353.

Input Format

One line with two integers V|V| and mm.

Output Format

One line, the answer.

4 5
312

Hint

For 100%100\% of the testdata, V1018|V| \le 10^{18} and m106m \le 10^6.

This problem uses bundled tests.

Translated by ChatGPT 5