Special Tables
Time limit2sMemory limit512 MB
Count the number of N by M tables with entries from 1 to C in which all rows are distinct and all columns are distinct, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming
- Solved
- No attempts yet
Problem
Jungyu likes tables filled with integers. He calls a table special when it satisfies all four conditions below.
- The table has rows and columns.
- Each cell holds one natural number that is at least and at most .
- For any two different rows and , there is at least one column such that the cells and hold different numbers.
- For any two different columns and , there is at least one row such that the cells and hold different numbers.
Given , , and , write a program that counts the special tables.
Input
The first line contains , , and . ()
Output
Print the number of special tables modulo 1,000,000,007.
Note
For the ten special tables are listed below. Each vertical pair of two-digit numbers is one table: the upper one is the first row and the lower one is the second row.
11 11 12 21 22 22 21 12 12 21
12 21 11 11 21 12 22 22 21 12