#P9832. Data Generation

Data Generation

Data Generation

Problem Description

Yoshinow2001 is making data for his problem. He wants to generate a random permutation of {0,,n1}\lbrace 0,\dots,n-1\rbrace , so he used the following algorithm: 图片 Here, we can assume that the function rand()modnrand() \bmod n is able to generate integer randomly in the set {0,,n1}\lbrace 0,\dots,n-1\rbrace with equal probability. Now Yoshinow2001 is concerned that this algorithm is not random enough ------ after all, if you want to randomize a permutation, the expected number of elements for aiia_i\neq i should be n1n-1. So he wants to ask what the mathematical expectation of the final ansans is.

Input

The first line of input is a positive integer T(1T105)T(1\leq T\leq 10^5) representing the number of data cases. For each cases consists of a single line of two integers n,mn,m, separated by a space. Where 1n10181\leq n\leq 10^{18},0m10180\leq m\leq 10^{18}, ensure that nn is not a multiple of 998 244 353998\ 244\ 353.

Output

For each cases, output a line with a positive integer representing the answer mod998 244 353\bmod 998\ 244\ 353.

Sample Input

3
1 0
1 1
2 1

Sample Output

0
0
1

Source

2023“钉耙编程”中国大学生算法设计超级联赛(4)