P8005 An Extra Requirement

题目背景

由于 Codeforces [[1]](https://codeforces.com/contest/1610/problem/I) [[2]](https://codeforces.com/contest/1591/problem/F) 能从 Atcoder [[1]](https://atcoder.jp/contests/agc017/tasks/agc017_d) [[2]](https://atcoder.jp/contests/arc115/tasks/arc115_e) 搬题,于是出(搬)题人也从 Atcoder [[3]](https://atcoder.jp/contests/agc054/tasks/agc054_e) 搬了一道。

题目描述

对于一个长度为 $N$ 的排列 $P$,你可以进行若干次如下操作:选三个位置 $x,y,z(x

输入格式

第一行输入一行一个正整数 $T$ 表示数据组数。 接下来 $T$ 行,每行两个正整数 $N,A$,分别表示排列 $P$ 的长度和排列 $P$ 的第一个数。

输出格式

输出 $T$ 行,每行一个整数表示答案,对 $998244353$ 取模。

说明/提示

**本题采用捆绑测试** | 子任务编号 | 分值 | 特殊限制 | | :----------: | :----------: | :----------: | | $0$ | $10$ | $T,N\le 8$ | | $1$ | $15$ | $T\le 5$,$N\le 100$ | | $2$ | $10$ | $T\le 5$,$N\le 1000$ | | $3$ | $15$ | $A=1$ | | $4$ | $15$ | $T\le 5$,$N\le 5\times 10^4$ | | $5$ | $15$ | $T\le 200$ | | $6$ | $20$ | 无特殊限制 | 对于所有数据,保证:$1\le T\le 10^5$,$1\le A\le N\le 10^5$。