{"raw_statement":[{"iden":"problem statement","content":"Given are integers $N$ and $A$. Find the number, modulo $998244353$, of permutations $P=(P_1,P_2,\\cdots,P_N)$ of $(1,2,\\cdots,N)$ that satisfy the following conditions.\n\n*   $P_1=A$.\n*   It is possible to repeat the following operation so that $P$ has just two elements.\n    *   Choose three **consecutive** elements $x$, $y$, and $z$. Here, $y<\\min(x,z)$ or $y>\\max(x,z)$ must hold. Then, erase $y$ from $P$.\n\nSolve $T$ test cases in an input file."},{"iden":"constraints","content":"*   $1 \\leq T \\leq 5 \\times 10^5$\n*   $3 \\leq N \\leq 10^6$\n*   $1 \\leq A \\leq N$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$T$\n$case_1$\n$case_2$\n$\\vdots$\n$case_T$\n\nEach case is in the following format:\n\n$N$ $A$"},{"iden":"sample input 1","content":"8\n3 1\n3 2\n3 3\n4 1\n4 2\n4 3\n4 4\n200000 10000"},{"iden":"sample output 1","content":"1\n2\n1\n3\n5\n5\n3\n621235018\n\nWhen $N=4,A=2$, one permutation that satisfies the condition is $P=(2,1,4,3)$. One way to make it have just two elements is as follows.\n\n*   Choose $(x,y,z)=(2,1,4)$ to erase $1$, resulting in $P=(2,4,3)$.\n*   Choose $(x,y,z)=(2,4,3)$ to erase $4$, resulting in $P=(2,3)$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}