#P9823. Good Poems

    ID: 22969 Type: Default 1000ms 256MiB

Good Poems

Good Poems

Once upon a time, there was a witch named Geor Autumn, who traveled across the world and collected stories. In the state of Shu, people loved poems. Here a poem is defined as a permutation ( (a_1, a_2, \ldots, a_n) ) of ( [n] ) (i.e. each ( a_i ) is a distinct integer from 1 to ( n )).

A poem is called good if for every index ( i ) with ( i > k ) and ( i \le n ), the following condition holds: [ a_i > \min{a_{i-k},a_{i-k+1},\ldots,a_{i-1}}. ] In other words, in every contiguous block of ( k+1 ) numbers (from ( a_{i-k} ) to ( a_i )), the last element is not the smallest one.

Given two integers ( n ) and ( k ), your task is to compute the number of good poems modulo ( 998244353 ).

Note: When ( k = 1 ) the condition forces the permutation to be strictly increasing, so there is exactly one good poem, while when ( k = n ) there is no restriction (the condition is vacuously true) and all ( n! ) permutations are good.

inputFormat

The input consists of a single line containing two integers ( n ) and ( k ) separated by a space. It is guaranteed that ( n ) is small (for example, ( n \le 10 )) so that a backtracking solution is feasible.

outputFormat

Output a single integer representing the number of good poems modulo ( 998244353 ).

sample

3 2
4