#ARC141B. [ARC141B] Increasing Prefix XOR

[ARC141B] Increasing Prefix XOR

Score : 500500 points

Problem Statement

You are given positive integers NN and MM.

Find the number of sequences A=(A1, A2, , AN)A=(A_1,\ A_2,\ \dots,\ A_N) of NN positive integers that satisfy the following conditions, modulo 998244353998244353.

  • 1A1<A2<<ANM1 \leq A_1 < A_2 < \dots < A_N \leq M.
  • B1<B2<<BNB_1 < B_2 < \dots < B_N, where Bi=A1A2AiB_i = A_1 \oplus A_2 \oplus \dots \oplus A_i.

Here, \oplus denotes bitwise XOR\mathrm{XOR}.

What is bitwise $\mathrm{XOR}$?

The bitwise $\mathrm{XOR}$ of non-negative integers $A$ and $B$, $A \oplus B$, is defined as follows:

  • When $A \oplus B$ is written in base two, the digit in the $2^k$'s place ($k \geq 0$) is $1$ if exactly one of $A$ and $B$ is $1$, and $0$ otherwise.
For example, we have 3 \oplus 5 = 6 (in base two: 011 \oplus 101 = 110).
Generally, the bitwise \mathrm{XOR} of k non-negative integers p_1, p_2, p_3, \dots, p_k is defined as (\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k). We can prove that this value does not depend on the order of p_1, p_2, p_3, \dots, p_k.

Constraints

  • 1NM<2601 \leq N \leq M < 2^{60}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the answer.

2 4
5

For example, (A1, A2)=(1, 3)(A_1,\ A_2)=(1,\ 3) counts, since A1<A2A_1 < A_2 and B1<B2B_1 < B_2 where B1=A1=1, B2=A1A2=2B_1=A_1=1,\ B_2=A_1\oplus A_2=2.

The other pairs that count are (A1, A2)=(1, 2), (1, 4), (2, 4), (3, 4)(A_1,\ A_2)=(1,\ 2),\ (1,\ 4),\ (2,\ 4),\ (3,\ 4).

4 4
0
10 123456789
205695670