Universal Cup Judging System

Universal Cup

Time Limit: 3.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

對於由 $1$ 到 $N$ 嘅每個整數,都有一個標記住嗰個整數嘅盒。另外,對於由 $1$ 到 $N$ 嘅每個整數,都有 $M$ 個標記住嗰個整數嘅波。

呢 $NM$ 個波會被打亂,然後分配入去 $N$ 個盒入面,每個盒恰好放 $M$ 個波。

總共有 $\frac{(NM)!}{(M!)^N}$ 種可能嘅放波方式(如果將所有波視為可區分嘅話),而且呢啲排列方式全部以相同嘅概率出現。

你將會對呢啲盒同波進行操作。一次操作包含以下步驟:

  1. 揀一個盒,然後行去嗰個盒前面。
  2. 如果嗰個盒入面冇波,就終止呢次操作。
  3. 從嗰個盒入面任揀一個波,將佢丟棄去盒出面。
  4. 最後,行去標記同啱啱丟棄嘅波嘅標記相同嘅盒前面,並返回步驟 $2$。

定義你嘅分數為直到所有 $NM$ 個波都被丟棄為止所需嘅操作次數。你希望最小化呢個分數。

請搵出當你採取最優策略嗰陣,分數嘅期望值對 $998244353$ 取模嘅結果。

Input

第一行按順序包含以空格分隔嘅 $N$ 同 $M$。($1 \le N \le 10^5, 1 \le M \le 100$)

Output

印出答案。

Examples

Input 1

2 2

Output 1

166374060

Input 2

3 1

Output 2

831870296

Input 3

100000 100

Output 3

402978825

Note

對於第一個範例,可能嘅波排列方式以及對應嘅最優操作方式如下:

  • 將兩個標記為 $1$ 嘅波放入盒 $1$,並將兩個標記為 $2$ 嘅波放入盒 $2$。(概率為 $1/6$)
    • 喺第一次操作入面,行去盒 $1$ 前面。喺嗰度攞出一個標記為 $1$ 嘅波,然後行去盒 $1$ 前面。跟住再攞出另一個標記為 $1$ 嘅波,並再次行去盒 $1$ 前面。呢個時候,盒 $1$ 係空嘅,所以終止操作。
    • 喺第二次操作入面,行去盒 $2$ 前面。喺嗰度攞出一個標記為 $2$ 嘅波,然後行去盒 $2$ 前面。跟住再攞出另一個標記為 $2$ 嘅波,並再次行去盒 $2$ 前面。呢個時候,盒 $2$ 係空嘅,所以終止操作。
    • 喺呢種情況下,可以達到嘅最細分數係 $2$。
  • 將一個標記為 $1$ 嘅波同一個標記為 $2$ 嘅波分別放入盒 $1$ 同盒 $2$ 入面。(概率為 $2/3$)
    • 喺第一次操作入面,行去盒 $1$ 前面。喺嗰度攞出一個標記為 $1$ 嘅波,然後行去盒 $1$ 前面。跟住攞出一個標記為 $2$ 嘅波,然後行去盒 $2$ 前面。跟住攞出一個標記為 $2$ 嘅波,然後行去盒 $2$ 前面。跟住攞出一個標記為 $1$ 嘅波,然後行去盒 $1$ 前面。呢個時候,盒 $1$ 係空嘅,所以終止操作。
    • 喺呢種情況下,可以達到嘅最細分數係 $1$。
  • 將兩個標記為 $2$ 嘅波放入盒 $1$,並將兩個標記為 $1$ 嘅波放入盒 $2$。(概率為 $1/6$)
    • 喺第一次操作入面,行去盒 $1$ 前面。喺嗰度攞出一個標記為 $2$ 嘅波,然後行去盒 $2$ 前面。跟住攞出一個標記為 $1$ 嘅波,然後行去盒 $1$ 前面。跟住攞出一個標記為 $2$ 嘅波,然後行去盒 $2$ 前面。跟住攞出一個標記為 $1$ 嘅波,然後行去盒 $1$ 前面。呢個時候,盒 $1$ 係空嘅,所以終止操作。
    • 喺呢種情況下,可以達到嘅最細分數係 $1$。

總括嚟講,最細分數有 $1/6$ 嘅概率係 $2$,有 $5/6$ 嘅概率係 $1$,所以整體嘅期望分數係 $7/6$。因此,輸出代表呢個數值對 $998244353$ 取模嘅 $166374060$。

期望值對 $998244353$ 取模嘅定義

可以證明,所求嘅期望值一定係有理數。另外,喺本題嘅限制條件下,如果將期望值寫成最簡分數 $\frac{y}{x}$,保證 $x$ 唔能夠被 $998244353$ 整除。

喺呢種情況下,喺 $0$ 到 $998244352$(包括首尾)之間存在唯一嘅整數 $z$ 滿足 $xz \equiv y \pmod{998244353}$。請輸出呢個 $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.