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 (109 + 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 (109 + 7).

Examples

Input

2 2 4
0 0
0 0


Output

48


Input

2 2 4
1 2
2 1


Output

0


Input

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

3628800


Input

2 6 10
1 2 3 4 5 6
0 0 0 0 0 0


Output

4096
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 11;
const int MOD = 1000000007;
int n, m, k, rem, fixMask, freeMask, A[MAXN];
vector<int> freeList;
int mat[MAXN][MAXN], mask[MAXN][MAXN];
int dfs(int r, int c, int chooseCnt) {
  if (c >= m) return dfs(r + 1, 0, chooseCnt);
  if (r >= n) return A[chooseCnt];
  mask[r][c] = (r ? mask[r - 1][c] : 0) | (c ? mask[r][c - 1] : 0);
  if (__builtin_popcount(mask[r][c]) + n - r + m - c - 1 > k) return 0;
  if (mat[r][c]) {
    if (mask[r][c] & (1 << (mat[r][c] - 1))) return 0;
    mask[r][c] |= 1 << (mat[r][c] - 1);
    return dfs(r, c + 1, chooseCnt);
  } else {
    int res = 0;
    for (int candidateMask = fixMask ^ (mask[r][c] & fixMask); candidateMask;
         candidateMask &= candidateMask - 1) {
      int idx = __builtin_ctz(candidateMask);
      mask[r][c] ^= 1 << idx;
      res += dfs(r, c + 1, chooseCnt);
      if (res >= MOD) res -= MOD;
      mask[r][c] ^= 1 << idx;
    }
    for (int idx = (0); idx < (chooseCnt); idx++) {
      if (mask[r][c] & (1 << freeList[idx])) continue;
      mask[r][c] ^= 1 << freeList[idx];
      res += dfs(r, c + 1, chooseCnt);
      if (res >= MOD) res -= MOD;
      mask[r][c] ^= 1 << freeList[idx];
    }
    if (chooseCnt < rem) {
      mask[r][c] ^= 1 << freeList[chooseCnt];
      res += dfs(r, c + 1, chooseCnt + 1);
      if (res >= MOD) res -= MOD;
      mask[r][c] ^= 1 << freeList[chooseCnt];
    }
    return res;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    puts("0");
  } else {
    freeMask = (1 << k) - 1;
    for (int i = (0); i < (n); i++)
      for (int j = (0); j < (m); j++) {
        scanf("%d", &mat[i][j]);
        if (mat[i][j]) {
          fixMask |= 1 << (mat[i][j] - 1);
          freeMask &= ~(1 << (mat[i][j] - 1));
        }
      }
    for (int tmpMask = freeMask; tmpMask; tmpMask &= tmpMask - 1) {
      freeList.push_back(__builtin_ctz(tmpMask));
    }
    rem = __builtin_popcount(freeMask);
    A[0] = 1;
    for (int i = (0); i < (rem); i++)
      A[i + 1] = (long long)A[i] * (rem - i) % MOD;
    printf("%d\n", dfs(0, 0, 0));
  }
  return 0;
}
