Codeforces Round 589 (Div. 2)
E
Another Filling the Grid
Codeforces
2300
原题
← DF →
翻译中…

You have $n \times n$ square grid and an integer $k$. Put an integer in each cell while satisfying the conditions below.

翻译中…
  • All numbers in the grid should be between $1$ and $k$ inclusive.
  • Minimum number of the $i$-th row is $1$ ($1 \le i \le n$).
  • Minimum number of the $j$-th column is $1$ ($1 \le j \le n$).
翻译中…

Find the number of ways to put integers in the grid. Since the answer can be very large, find the answer modulo $(10^{9} + 7)$.

翻译中…

image These are the examples of valid and invalid grid when $n=k=2$.

翻译中…

Input

翻译中…

The only line contains two integers $n$ and $k$ ($1 \le n \le 250$, $1 \le k \le 10^{9}$).

翻译中…

Output

翻译中…

Print the answer modulo $(10^{9} + 7)$.

翻译中…

Note

翻译中…

In the first example, following $7$ cases are possible.

翻译中…

image

翻译中…

In the second example, make sure you print the answer modulo $(10^{9} + 7)$.

翻译中…

样例

Input #1
2 2
Output #1
7
InputCopy OutputCopy
Input #2
123 456789
Output #2
689974806
InputCopy OutputCopy
题目信息
题号
1228E
时间限制
1 s
内存限制
256 MB
标签
组合数学
动态规划
数学

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