{"raw_statement":[{"iden":"statement","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"},{"iden":"input","content":"The 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$)."},{"iden":"output","content":"For each test case, output one line containing the answer modulo $998244353$."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**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 $.","simple_statement":"You are given a permutation of length n. You can swap any two elements that are exactly c positions apart. Count how many distinct permutations you can get, modulo 998244353.","has_page_source":false}