#ARC154E. [ARC154E] Reverse and Inversion

[ARC154E] Reverse and Inversion

Score : 900900 points

Problem Statement

For a permutation Q=(Q1,Q2,,QN)Q=(Q_1,Q_2,\dots,Q_N) of (1,2,,N)(1,2,\dots,N), let f(Q)f(Q) be the following value:

$$j-i$$$$(i,j)$$$$1 \le i < j \le N$$$$Q_i > Q_j$$You are given a permutation $P=(P_1,P_2,\dots,P_N)$ of $(1,2,\dots,N)$. $$

Let us repeat the following operation MM times.

  • Choose a pair of integers (i,j)(i,j) such that 1ijN1 \le i \le j \le N. Reverse Pi,Pi+1,,PjP_i,P_{i+1},\dots,P_j. Formally, replace the values of Pi,Pi+1,,PjP_i,P_{i+1},\dots,P_j with Pj,Pj1,,PiP_j,P_{j-1},\dots,P_i simultaneously.

There are (N(N+1)2)M\left(\frac{N(N+1)}{2}\right)^{M} ways to repeat the operation. Assume that we have computed f(P)f(P) for all those ways.

Find the sum of these (N(N+1)2)M\left(\frac{N(N+1)}{2}\right)^{M} values, modulo 998244353998244353.

Constraints

  • 1N,M2×1051 \le N,M \le 2 \times 10^5
  • (P1,P2,,PN)(P_1,P_2,\dots,P_N) is a permutation of (1,2,,N)(1,2,\dots,N).

Input

The input is given from Standard Input in the following format:

NN MM

P1P_1 P2P_2 \dots PNP_N

Output

Print a single line containing the answer.

2 1
1 2
1

There are three ways to perform the operation, as follows.

  • Choose (i,j)=(1,1)(i,j)=(1,1), making P=(1,2)P=(1,2), where f(P)=0f(P)=0.
  • Choose (i,j)=(1,2)(i,j)=(1,2), making P=(2,1)P=(2,1), where f(P)=1f(P)=1.
  • Choose (i,j)=(2,2)(i,j)=(2,2), making P=(1,2)P=(1,2), where f(P)=0f(P)=0.

Thus, the answer is 0+1+0=10+1+0=1.

3 2
3 2 1
90
10 2023
5 8 1 9 3 10 4 7 2 6
543960046