atcoder#ABC220E. [ABC220E] Distance on Large Perfect Binary Tree

[ABC220E] Distance on Large Perfect Binary Tree

Score : 500500 points

Problem Statement

We have a tree with 2N12^N-1 vertices. The vertices are numbered 11 through 2N12^N-1. For each 1i<2N11\leq i < 2^{N-1}, the following edges exist:

  • an undirected edge connecting Vertex ii and Vertex 2i2i,
  • an undirected edge connecting Vertex ii and Vertex 2i+12i+1.

There is no other edge.

Let the distance between two vertices be the number of edges in the simple path connecting those two vertices.

Find the number, modulo 998244353998244353, of pairs of vertices (i,j)(i, j) such that the distance between them is DD.

Constraints

  • 2N1062 \leq N \leq 10^6
  • 1D2×1061 \leq D \leq 2\times 10^6
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN DD

Output

Print the answer.

3 2
14

The following figure describes the given tree.

Figure

There are 1414 pairs of vertices such that the distance between them is 22: $(1,4),(1,5),(1,6),(1,7),(2,3),(3,2),(4,1),(4,5),(5,1),(5,4),(6,1),(6,7),(7,1),(7,6)$.

14142 17320
11284501