F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Shattrath City

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 379    Accepted Submission(s): 126


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.
 

Sample Input
3 3 5 5 10 100000 200000
 

Sample Output
123 8001745 700646201
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-12 10:17:41, Gzip enabled