Another Filling the Grid
시간 제한1초메모리 제한1024 MB
각 행과 각 열에 1이 하나 이상 들어가도록 1부터 k까지의 정수로 n×n 격자를 채우는 경우의 수를 1e9+7로 나눈 나머지로 구한다.
문제
You have square grid and an integer . Put an integer in each cell while satisfying the conditions below.
- All numbers in the grid should be between and inclusive.
- Minimum number of the -th row is ().
- Minimum number of the -th column is ().
Find the number of ways to put integers in the grid. Since the answer can be very large, find the answer modulo .

These are the examples of valid and invalid grid when .
입력
The only line contains two integers and (, ).
출력
Print the answer modulo .
힌트
In the first example, following cases are possible.

In the second example, make sure you print the answer modulo .