{"problem":{"name":"Ex - Colorfulness","description":{"content":"There are $N$ balls numbered $1$ through $N$. Ball $i$ is painted in Color $a_i$. For a permutation $P = (P_1, P_2, \\dots, P_N)$ of $(1, 2, \\dots, N)$, let us define $C(P)$ as follows: *   The number","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":8000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc260_h"},"statements":[{"statement_type":"Markdown","content":"There are $N$ balls numbered $1$ through $N$. Ball $i$ is painted in Color $a_i$.\nFor a permutation $P = (P_1, P_2, \\dots, P_N)$ of $(1, 2, \\dots, N)$, let us define $C(P)$ as follows:\n\n*   The number of pairs of adjacent balls with different colors when Balls $P_1, P_2, \\dots, P_N$ are lined up in a row in this order.\n\nLet $S_N$ be the set of all permutations of $(1, 2, \\dots, N)$. Also, let us define $F(k)$ by:\n\n$\\displaystyle F(k) = \\left(\\sum_{P \\in S_N}C(P)^k \\right) \\bmod 998244353$.\n\nEnumerate $F(1), F(2), \\dots, F(M)$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 2.5 \\times 10^5$\n*   $1 \\leq M \\leq 2.5 \\times 10^5$\n*   $1 \\leq a_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$ $M$\n$a_1$ $a_2$ $\\dots$ $a_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc260_h","tags":[],"sample_group":[["3 4\n1 1 2","8 12 20 36\n\nHere is the list of all possible pairs of $(P, C(P))$.\n\n*   If $P=(1,2,3)$, then $C(P) = 1$.\n*   If $P=(1,3,2)$, then $C(P) = 2$.\n*   If $P=(2,1,3)$, then $C(P) = 1$.\n*   If $P=(2,3,1)$, then $C(P) = 2$.\n*   If $P=(3,1,2)$, then $C(P) = 1$.\n*   If $P=(3,2,1)$, then $C(P) = 1$.\n\nWe may obtain the answers by assigning these values into $F(k)$. For instance, $F(1) = 1^1 + 2^1 + 1^1 + 2^1 + 1^1 + 1^1 = 8$."],["2 1\n1 1","0"],["10 5\n3 1 4 1 5 9 2 6 5 3","30481920 257886720 199419134 838462446 196874334"]],"created_at":"2026-03-03 11:01:14"}}