{"problem":{"name":"Ex - Rearranging Problem","description":{"content":"There are $N$ people called Person $1$, Person $2$, $\\dots$, Person $N$, lined up in a row in the order of $(1,2,\\dots,N)$ from the front. Person $i$ is wearing Color $c_i$.   Takahashi repeated the f","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc247_h"},"statements":[{"statement_type":"Markdown","content":"There are $N$ people called Person $1$, Person $2$, $\\dots$, Person $N$, lined up in a row in the order of $(1,2,\\dots,N)$ from the front. Person $i$ is wearing Color $c_i$.  \nTakahashi repeated the following operation $K$ times: choose two People $i$ and $j$ arbitrarily and swap the positions of Person $i$ and Person $j$.  \nAfter the $K$ operations have ended, the color that the $i$\\-th person from the front is wearing coincided with $c_i$, for every integer $i$ such that $1 \\leq i \\leq N$.  \nHow many possible permutations of people after the $K$ operations are there? Find the count modulo $998244353$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 200000$\n*   $1 \\leq K \\leq 10^9$\n*   $1 \\leq c_i \\leq N$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n$c_1$ $c_2$ $\\dots$ $c_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc247_h","tags":[],"sample_group":[["4 1\n1 1 2 1","3\n\nHere is a comprehensive list of possible Takahashi's operations and permutations of people after each operation.\n\n*   Swap the positions of Person $1$ and Person $2$, resulting in a permutation $(2, 1, 3, 4)$.\n*   Swap the positions of Person $1$ and Person $4$, resulting in a permutation $(4, 2, 3, 1)$.\n*   Swap the positions of Person $2$ and Person $4$, resulting in a permutation $(1, 4, 3, 2)$."],["3 3\n1 1 2","1\n\nHere is an example of a possible sequence of Takahashi's operations.\n\n*   In the $1$\\-st operation, he swaps the positions of Person $1$ and Person $3$, resulting in a permutation $(3, 2, 1)$.  \n    In the $2$\\-nd operation, he swaps the positions of Person $2$ and Person $3$, resulting in a permutation $(2, 3, 1)$.  \n    In the $3$\\-rd operation, he swaps the positions of Person $1$ and Person $3$, resulting in a permutation $(2, 1, 3)$.\n\nNote that, during the sequence of operations, the color that the $i$\\-th person from the front is wearing does not necessarily coincide with $c_i$."],["10 4\n2 7 1 8 2 8 1 8 2 8","132"]],"created_at":"2026-03-03 11:01:13"}}