#ABC247H. [ABC247Ex] Rearranging Problem

[ABC247Ex] Rearranging Problem

Score : 600600 points

Problem Statement

There are NN people called Person 11, Person 22, \dots, Person NN, lined up in a row in the order of (1,2,,N)(1,2,\dots,N) from the front. Person ii is wearing Color cic_i. Takahashi repeated the following operation KK times: choose two People ii and jj arbitrarily and swap the positions of Person ii and Person jj. After the KK operations have ended, the color that the ii-th person from the front is wearing coincided with cic_i, for every integer ii such that 1iN1 \leq i \leq N. How many possible permutations of people after the KK operations are there? Find the count modulo 998244353998244353.

Constraints

  • 2N2000002 \leq N \leq 200000
  • 1K1091 \leq K \leq 10^9
  • 1ciN1 \leq c_i \leq N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

c1c_1 c2c_2 \dots cNc_N

Output

Print the answer.

4 1
1 1 2 1
3

Here is a comprehensive list of possible Takahashi's operations and permutations of people after each operation.

  • Swap the positions of Person 11 and Person 22, resulting in a permutation (2,1,3,4)(2, 1, 3, 4).
  • Swap the positions of Person 11 and Person 44, resulting in a permutation (4,2,3,1)(4, 2, 3, 1).
  • Swap the positions of Person 22 and Person 44, resulting in a permutation (1,4,3,2)(1, 4, 3, 2).
3 3
1 1 2
1

Here is an example of a possible sequence of Takahashi's operations.

  • In the 11-st operation, he swaps the positions of Person 11 and Person 33, resulting in a permutation (3,2,1)(3, 2, 1). In the 22-nd operation, he swaps the positions of Person 22 and Person 33, resulting in a permutation (2,3,1)(2, 3, 1). In the 33-rd operation, he swaps the positions of Person 11 and Person 33, resulting in a permutation (2,1,3)(2, 1, 3).

Note that, during the sequence of operations, the color that the ii-th person from the front is wearing does not necessarily coincide with cic_i.

10 4
2 7 1 8 2 8 1 8 2 8
132