8647: Shattrath City

内存限制:512 MB 时间限制:3 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

Velen calls a sequence "n-beautiful", if it satisfies the following three conditions:

  1. Its length is larger than n.
  2. Each element of the sequence is a positive integer n.
  3. Each of its continuous subsequence of length n is NOT a permutation of 1,2...n

Velen takes inspiration from "n-beautiful" sequences, so he is interested in the number of "n-beautiful" sequences of length mm.

Could you help him?

Since the answer can be very large, you only need to output the answer modulo 998244353.

输入格式

The input consists of multiple test cases.

The first line contains an integer T (1T4) denoting the number of test cases.

Each test case consists of only one line containing two integers n,m (3n<m2×105).

输出格式

For each test case, output one line containing one integer indicating the answer.

输入样例 复制

3
3 5
5 10
100000 200000

输出样例 复制

123
8001745
700646201