CF1228E.Another Filling the Grid

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

  • All numbers in the grid should be between 11 and kk inclusive.
  • Minimum number of the ii -th row is 11 ( 1in1 \le i \le n ).
  • Minimum number of the jj -th column is 11 ( 1jn1 \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 (109+7)(10^{9} + 7) .

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

输入格式

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

输出格式

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

输入输出样例

  • 输入#1

    2 2
    

    输出#1

    7
    
  • 输入#2

    123 456789
    

    输出#2

    689974806
    

说明/提示

In the first example, following 77 cases are possible.

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

首页