AT_abc483_g [ABC483G] Qualification

Description

You are given integers $ N,K $ . It is guaranteed that the given integers satisfy $ \displaystyle K \le \frac N2 $ . For permutations $ P=(P_1,P_2,\ldots,P_N),Q=(Q_1,Q_2,\ldots,Q_N) $ of $ (1,2,\ldots,N) $ , define $ f(P,Q) $ as follows: > $ N $ people, person $ 1 $ through person $ N $ , participated in $ 2 $ contests, contest A and contest B. Person $ i $ $ (1\le i\le N) $ placed $ P_i $ -th in contest A and $ Q_i $ -th in contest B. > > Consider choosing $ 2K $ of these $ N $ people by the following $ 2 $ selection methods. > > - Method ①: Choose the $ K $ people with the best ranks in contest A. Then, among the $ N-K $ people not yet chosen, choose the $ K $ people with the best ranks in contest B. > - Method ②: Choose the $ K $ people with the best ranks in contest B. Then, among the $ N-K $ people not yet chosen, choose the $ K $ people with the best ranks in contest A. > > Let $ f(P,Q) $ be the number of people who are chosen by method ① but not chosen by method ②. There are $ N!^2 $ pairs $ (P,Q) $ of permutations of $ (1,2,\ldots,N) $ . Find the sum of $ f(P,Q) $ over all of them, modulo $ 998244353 $ . You are given $ T $ test cases; solve each of them.

Input Format

The input is given from Standard Input in the following format: > $ T $ $ \text{case}_1 $ $ \text{case}_2 $ $ \vdots $ $ \text{case}_T $ Each test case is given in the following format: > $ N $ $ K $

Output Format

Print the answers to the test cases in order, separated by newlines.

Explanation/Hint

### Sample Explanation 1 Consider the $ 1 $ -st test case. For example, when $ P=(2,1,3),Q=(3,1,2) $ , the people chosen by method ① are persons $ 2 $ and $ 3 $ , and the people chosen by method ② are persons $ 1 $ and $ 2 $ . Therefore, $ f(P,Q)=1 $ for this pair $ P,Q $ . There are $ 6 $ pairs $ (P,Q) $ with $ f(P,Q)=1 $ , and $ f(P,Q)=0 $ holds for the remaining $ 30 $ pairs $ (P,Q) $ . Therefore, the answer is $ 6\times 1+30\times 0=6 $ . ### Constraints - $ 1\le T\le 2\times 10^5 $ - $ 2\le N\le 10^6 $ - $ \displaystyle 1\le K \le \frac N2 $ - The sum of $ N $ over all test cases is at most $ 10^6 $ . - All input values are integers.