Croc Champ 2013 - Round 2 (Div. 2 Edition)
D
Distinct Paths
Codeforces
未评级
原题
← CE →
翻译中…

You have a rectangular $*n* × *m*$-cell board. Some cells are already painted some of $*k*$ colors. You need to paint each uncolored cell one of the $*k*$ colors so that any path from the upper left square to the lower right one doesn't contain any two cells of the same color. The path can go only along side-adjacent cells and can only go down or right.

翻译中…

Print the number of possible paintings modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

Input

翻译中…

The first line contains three integers $*n*, *m*, *k*$ $(1 ≤ *n*, *m* ≤ 1000, 1 ≤ *k* ≤ 10)$. The next $*n*$ lines contain $*m*$ integers each — the board. The first of them contains $*m*$ uppermost cells of the board from the left to the right and the second one contains $*m*$ cells from the second uppermost row and so on. If a number in a line equals 0, then the corresponding cell isn't painted. Otherwise, this number represents the initial color of the board cell — an integer from 1 to $*k*$.

翻译中…

Consider all colors numbered from 1 to $*k*$ in some manner.

翻译中…

Output

翻译中…

Print the number of possible paintings modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

样例

Input #1
2 2 4
0 0
0 0
Output #1
48
InputCopy OutputCopy
Input #2
2 2 4
1 2
2 1
Output #2
0
InputCopy OutputCopy
Input #3
5 6 10
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Output #3
3628800
InputCopy OutputCopy
Input #4
2 6 10
1 2 3 4 5 6
0 0 0 0 0 0
Output #4
4096
InputCopy OutputCopy
题目信息
题号
299D
时间限制
2 s
内存限制
256 MB

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