Universal Cup Judging System

Universal Cup

حد الوقت: 3.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

There is one box labeled with each integer from $1$ to $N$. Also, for each integer from $1$ to $N$, there are $M$ balls labeled with that integer.

These $NM$ balls are shuffled and then distributed into the $N$ boxes, with exactly $M$ balls placed into each box.

There are $\frac{(NM)!}{(M!)^N}$ possible ways to place the balls (if all balls are considered distinguishable), and all of these arrangements occur with equal probability.

You will perform operations on these boxes and balls. One operation consists of the following steps.

  1. Choose one box and go in front of that box.
  2. If there is no ball in that box, terminate the operation.
  3. Choose any one ball from that box and discard it outside the box.
  4. Finally, go in front of the box whose label matches the label of the ball most recently discarded, and return to step $2$.

Define your score as the number of operations required until all $NM$ balls have been discarded. You want to minimize this score.

Find the expected value of the score when you act optimally, modulo $998244353$.

Input

The first line contains $N$ and $M$ in this order, separated by spaces. ($1 \le N \le 10^5, 1 \le M \le 100$)

Output

Print the answer.

Examples

Input 1

2 2

Output 1

166374060

Input 2

3 1

Output 2

831870296

Input 3

100000 100

Output 3

402978825

Note

For the first example, the possible ball arrangements and the corresponding optimal ways of operating are as follows.

  • Put two balls labeled $1$ into box $1$, and two balls labeled $2$ into box $2$. (Probability $1/6$)
    • In the first operation, go in front of box $1$. From there, take out a ball labeled $1$ and go in front of box $1$. Then take out another ball labeled $1$ and go in front of box $1$ again. At this point, box $1$ is empty, so terminate the operation.
    • In the second operation, go in front of box $2$. From there, take out a ball labeled $2$ and go in front of box $2$. Then take out another ball labeled $2$ and go in front of box $2$ again. At this point, box $2$ is empty, so terminate the operation.
    • In this case, the minimum achievable score is $2$.
  • Put one ball labeled $1$ and one ball labeled $2$ into each of box $1$ and box $2$. (Probability $2/3$)
    • In the first operation, go in front of box $1$. From there, take out a ball labeled $1$ and go in front of box $1$. Then take out a ball labeled $2$ and go in front of box $2$. Then take out a ball labeled $2$ and go in front of box $2$. Then take out a ball labeled $1$ and go in front of box $1$. At this point, box $1$ is empty, so terminate the operation.
    • In this case, the minimum achievable score is $1$.
  • Put two balls labeled $2$ into box $1$, and two balls labeled $1$ into box $2$. (Probability $1/6$)
    • In the first operation, go in front of box $1$. From there, take out a ball labeled $2$ and go in front of box $2$. Then take out a ball labeled $1$ and go in front of box $1$. Then take out a ball labeled $2$ and go in front of box $2$. Then take out a ball labeled $1$ and go in front of box $1$. At this point, box $1$ is empty, so terminate the operation.
    • In this case, the minimum achievable score is $1$.

In summary, the minimum score is $2$ with probability $1/6$, and the minimum score is $1$ with probability $5/6$, so the expected score overall is $7/6$. Therefore, output $166374060$, which represents this value modulo $998244353$.

Definition of expected value modulo $998244353$

It can be proven that the expected value to be found is always a rational number. Also, under the constraints of this problem, if the expected value is written as a reduced fraction $\frac{y}{x}$, it is guaranteed that $x$ is not divisible by $998244353$.

In this case, there exists a unique integer $z$ between $0$ and $998244352$, inclusive, satisfying $xz \equiv y \pmod{998244353}$. Output this $z$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1526EditorialOpen题解jianglyView

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.