#abc267g. [abc267_g]Increasing K Times

[abc267_g]Increasing K Times

Problem Statement

You are given an integer sequence A=(A1,dots,AN)A = (A_1, \\dots, A_N) of length NN.

Find the number, modulo 998244353998244353, of permutations P=(P1,dots,PN)P = (P_1, \\dots, P_N) of (1,2,dots,N)(1, 2, \\dots, N) such that:

  • there exist exactly KK integers ii between 11 and (N1)(N-1) (inclusive) such that APiltAPi+1A_{P_i} \\lt A_{P_{i + 1}}.

Constraints

  • 2leqNleq50002 \\leq N \\leq 5000
  • 0leqKleqN10 \\leq K \\leq N - 1
  • 1leqAileqN,(1leqileqN)1 \\leq A_i \\leq N \\, (1 \\leq i \\leq N)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK A1A_1 ldots\\ldots ANA_N

Output

Print the answer.


Sample Input 1

4 2
1 1 2 2

Sample Output 1

4

Four permutations satisfy the condition: $P = (1, 3, 2, 4), (1, 4, 2, 3), (2, 3, 1, 4), (2, 4, 1, 3)$.


Sample Input 2

10 3
3 1 4 1 5 9 2 6 5 3

Sample Output 2

697112