#ARC135F. [ARC135F] Delete 1, 4, 7, ...

[ARC135F] Delete 1, 4, 7, ...

Score : 10001000 points

Problem Statement

You are given an integer NN. On an integer sequence A=(1,2,,N)A = (1, 2, \ldots, N), let us do the operation below exactly KK times.

  • Let nn be the current number of terms in AA. For all ii such that 1in1\leq i \leq n and i1(mod3)i\equiv 1\pmod{3}, delete the ii-th term of AA, simultaneously.

Find the sum of the terms of AA after KK operations, modulo 998244353998244353.

Constraints

  • 1N10141\leq N\leq 10^{14}
  • 1K1001\leq K\leq 100

Input

Input is given from Standard Input from the following format:

NN KK

Output

Print the sum of the terms of AA after KK operations, modulo 998244353998244353.

10 2
25
  • Initially, we have A=(1,2,3,4,5,6,7,8,9,10)A = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10).
  • After the first operation, we have A=(2,3,5,6,8,9)A = (2, 3, 5, 6, 8, 9).
  • After the second operation, we have A=(3,5,8,9)A = (3, 5, 8, 9).
  • The sum of the terms here is 3+5+8+9=253 + 5 + 8 + 9 = 25.
10 10
0
  • After the second operation, we have A=(3,5,8,9)A = (3, 5, 8, 9) (same as Sample Input 1).
  • After the third operation, we have A=(5,8)A = (5, 8).
  • After the fourth operation, we have A=(8)A = (8).
  • After the fifth operation, AA is empty.
  • In the sixth and subsequent operations, AA remains empty, where the sum of the terms is 00.
10000 10
862816