QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 256 MB Puntuación total: 100

#1603. Added 0 by EI

Estadísticas

Given $n$ and $m$.

Find the number of distinct sequences of positive integers $a_1, a_2, \dots, a_n$ such that for all $1 \leq i \leq n$, $1 \leq a_i \leq m$, and there exist no $1 \leq i < j \leq n$ satisfying $\max\limits_{k=1}^i a_k = \min\limits_{k=j}^n a_k$. Output the answer modulo $998244353$.

Input

The first line contains a positive integer $T$, representing the number of test cases.

Each of the following $T$ lines contains two positive integers $n$ and $m$.

Output

For each test case, output a single integer on a new line representing the answer modulo $998244353$.

Subtasks

For $50\%$ of the data, $n \leq 50$.

For $100\%$ of the data, $1 \leq T \leq 10^5$, $1 \leq n \leq 300$, $1 \leq m \leq 10^9$.

Examples

Input 1

3
3 2
3 3
4 10

Output 1

2
12
7500

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.