#ABC256G. [ABC256G] Black and White Stones

[ABC256G] Black and White Stones

Score : 600600 points

Problem Statement

There is a regular NN-gon with side length DD.

Starting from a vertex, we place black or white stones on the circumference at intervals of 11. As a result, each edge of the NN-gon will have (D+1)(D+1) stones on it, for a total of NDND stones.

How many ways are there to place stones so that all edges have the same number of white stones on them? Find the count modulo 998244353998244353.

Constraints

  • 3N10123 \leq N \leq 10^{12}
  • 1D1041 \leq D \leq 10^4
  • 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
10

There are 1010 ways, as follows:

Figure

299792458 3141
138897974

Find the count modulo 998244353998244353.