AtCoder Beginner Contest 386
G
Many MST
AtCoder
⌀ 2930
原题
翻译中…

Problem Statement

翻译中…

You are given positive integers $N$ and $M$. Consider a weighted complete graph with $N$ vertices labeled from $1$ to $N$, where the weight of each edge is an integer between $1$ and $M$, inclusive. There are $M^{N(N-1)/2}$ such graphs. For each of them, consider the sum of the weights of the edges included in its Minimum Spanning Tree. What is the total of these sums? Print the result modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $2 \le N \le 500$
  • $1 \le M \le 500$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N M

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3 2
Output #1
21
Here are eight complete graphs with three vertices where edge weights are $1$ or $2$. The edges in each graph’s MST are highlighted in red in the figure below. ![image](https://img.atcoder.jp/abc386/f22490c7e125872d186e7dbb13165ebc.png) The sums of the MST edges for these graphs are $2,2,2,3,2,3,3,4$, so the total is $2+2+2+3+2+3+3+4=21$.
Input #2
2 100
Output #2
5050
Input #3
20 24
Output #3
707081320
题目信息
题号
abc386_g
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。