QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#8638. Sorting

Statistics

For an integer sequence $A=(a_1, a_2, \dots, a_n)$, consider the following recursive process: first, choose a value $a_k$ from $A$ uniformly at random. Arrange all elements in $A$ that are smaller than $a_k$ in their original relative order to form a sequence $A_1$, and arrange all elements in $A$ that are greater than $a_k$ in their original relative order to form a sequence $A_2$. Then, repeat this process for sequences $A_1$ and $A_2$ until the sequences are empty. The time cost of one recursion is defined as the sum of the lengths of all sequences generated during the process (including the initial sequence). Since the recursion is non-deterministic, let $T(A)$ be the expected time cost of performing this process on sequence $A$.

Given $n$ and $m$, calculate the sum of $T(A)$ for all integer sequences $A$ of length $n$ such that $1 \le a_i \le m$ for all $i=1, 2, \dots, n$. The answer should be taken modulo 998244353.

Input

The input consists of a single line containing two positive integers $n$ and $m$, representing the length of the sequence and the range of the elements, respectively.

Output

Output a single integer representing the sum of $T(A)$ modulo 998244353.

Examples

Input 1

3 2

Output 1

32

Input 2

5 4

Output 2

9236

Input 3

25 15

Output 3

907094177

Constraints

For $20\%$ of the data: $n, m \le 5$.

For $50\%$ of the data: $n, m \le 30$.

For another $20\%$ of the data: $n \le 5, m \le 10^9$.

For all test data, it is guaranteed that $1 \le n \le 100$ and $1 \le m \le 10^9$.

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.