#x1010. CF1228E Another Filling the Grid
CF1228E Another Filling the Grid
Another Filling the Grid
题面翻译
给定一个 的矩阵,用 的数填充,每行每列最小值均为 ,问有多少填法,对 取模。
。
题目描述
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 .
样例 #1
样例输入 #1
2 2
样例输出 #1
7
样例 #2
样例输入 #2
123 456789
样例输出 #2
689974806
提示
In the first example, following cases are possible.
In the second example, make sure you print the answer modulo .