{"problem":{"name":"J. Permutation","description":{"content":"You are given a permutation $p_1, p_2, \\\\dots, p_n$. You can do the following operations repeatedly: You want to know how many distinct permutations you can get using operations. The answer can be la","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10247J"},"statements":[{"statement_type":"Markdown","content":"You are given a permutation $p_1, p_2, \\\\dots, p_n$. You can do the following operations repeatedly:\n\nYou want to know how many distinct permutations you can get using operations. The answer can be large, output the answer modulo $998244353$.\n\nThe first line contains an integer $T$ denoting the number of test cases ($1 <= T <= 100000$).\n\nThe first line in a test case contains two integers $n$ and $c$ ($2 <= c <= 500000$, $2 <= n <= 500000$). The sum of $n$ over all test cases does not exceed $500000$.\n\nThe second line in a test case contains a permutation $p_1, \\\\dots, p_n$ ($1 <= p_i <= n$).\n\nFor each test case, output one line containing the answer modulo $998244353$.\n\n## Input\n\nThe first line contains an integer $T$ denoting the number of test cases ($1 <= T <= 100000$).The first line in a test case contains two integers $n$ and $c$ ($2 <= c <= 500000$, $2 <= n <= 500000$). The sum of $n$ over all test cases does not exceed $500000$.The second line in a test case contains a permutation $p_1, \\\\dots, p_n$ ($1 <= p_i <= n$).\n\n## Output\n\nFor each test case, output one line containing the answer modulo $998244353$.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ n, c \\in \\mathbb{Z} $ with $ 2 \\leq c \\leq 500000 $, $ 2 \\leq n \\leq 500000 $.  \n- Let $ p = (p_1, p_2, \\dots, p_n) $ be a permutation of $ \\{1, 2, \\dots, n\\} $.  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq 100000 $  \n2. $ \\sum_{\\text{all test cases}} n \\leq 500000 $  \n3. $ 2 \\leq c \\leq 500000 $, $ 2 \\leq n \\leq 500000 $  \n\n**Operation**  \nYou may repeatedly perform the following:  \n- Choose any contiguous subsequence of length $ c $ and reverse it.  \n\n**Objective**  \nFor each test case, compute the number of distinct permutations reachable from $ p $ via any sequence of such operations, modulo $ 998244353 $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10247J","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}