#P7232. Shattrath City

    ID: 6089 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2022“杭电杯”中国大学生算法设计超级联赛(8)

Shattrath City

Problem Description

$\space \space$**Why would a *prophet* not warn of calamity?*

$\space \space$**Why didn't you warn the world about the Cataclysm?* The simple, logical question of a mortal child echoed accusingly throughout the silent chamber, distracting the Prophet from his contemplation of the Light. Velen had evaded rather than answered, obscured instead of illuminating. He was surprised at himself. *Am I still capable of deception? Even after all this time? Both within and without?*

$\space \space$**Velen is sinking in self-doubt.*


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 $\leq 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 $m$.

Could you help him?

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

Input

The input consists of multiple test cases.

The first line contains an integer $T (1\leq T \leq 4)$ denoting the number of test cases.

Each test case consists of only one line containing two integers $n,m\ (3\leq n < m \leq 2\times 10^5)$.

Output

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

3 3 5 5 10 100000 200000
123 8001745 700646201