atcoder#ARC146F. [ARC146F] Simple Solitaire

[ARC146F] Simple Solitaire

Score : 12001200 points

Problem Statement

The following process is carried out on a permutation PP of (1,2,,N)(1,2,\dots,N).

We have NN cards, numbered 11 to NN. Card ii has the integer PiP_i written on it.

There are an integer X=1X=1 and a boy called PCT, who initially has nothing. PCT does the following procedure for each i=1,2,,Ni=1,2,\dots,N in this order.

  • Get Card ii. Then, repeat the following action as long as he has a card with XX written on it:
  • eat the card with XX written on it, and then add 11 to XX.
  • If PCT currently has MM or more cards, throw away all cards he has and terminate the process, without performing any more procedures.

Here, let us define the score of the permutation PP as follows:

  • if the process is terminated by throwing away cards, the score of PP is 00;
  • if the process is carried out through the end without throwing away cards, the score of PP is i=1N1\prod_{i=1}^{N-1} (( the number of cards PCT has at the end of the ii-th procedure )).

There are N!N! permutations PP of (1,2,,N)(1,2,\dots,N). Find the sum of the scores of all those permutations, modulo 998244353998244353.

Constraints

  • 2N2×1052 \le N \le 2 \times 10^5
  • 2MN2 \le M \le N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the answer.

3 2
1

For P=(3,1,2)P=(3,1,2), the process goes as follows.

  • The first procedure:- PCT gets Card 11.
    • PCT currently has 11 card, so he goes on.
  • PCT gets Card 11.
  • PCT currently has 11 card, so he goes on.
  • The second procedure:- PCT gets Card 22.
    • PCT eats Card 22 and make X=2X = 2.
    • PCT currently has 11 card, so he goes on.
  • PCT gets Card 22.
  • PCT eats Card 22 and make X=2X = 2.
  • PCT currently has 11 card, so he goes on.
  • The third procedure:- PCT gets Card 33.
    • PCT eats Cards 1,31,3 and make X=4X = 4.
    • PCT currently has 00 cards, so he goes on.
  • PCT gets Card 33.
  • PCT eats Cards 1,31,3 and make X=4X = 4.
  • PCT currently has 00 cards, so he goes on.

The process is carried out through the end, so the score of (3,1,2)(3,1,2) is 1×1=11 \times 1 = 1.

Other than (3,1,2)(3,1,2), there is no permutation with a score of 11 or greater, so the answer is 11.

3 3
5
146146 146
103537573