#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int res = 0;
int board[10][10], dp[10][10], vis[11];
int n, m, k;
int cnt(int t) {
  int res = 0;
  while (t > 0) {
    res += (t & 1);
    t >>= 1;
  }
  return res;
}
void dfs(int curr) {
  if (curr == n * m) {
    res = (res + 1) % mod;
    return;
  }
  int x = curr / m, y = curr % m;
  int z = (x > 0 ? dp[x - 1][y] : 0) | (y > 0 ? dp[x][y - 1] : 0);
  if (m + n - x - y - 1 > k - cnt(z)) return;
  int sum = -1, pre = 0;
  if (board[x][y] == 0) {
    for (int i = 1; i <= k; i++) {
      if (!(z & (1 << i))) {
        dp[x][y] = z;
        if (!vis[i]) {
          if (sum >= 0) {
            res += sum;
            res %= mod;
            continue;
          }
          pre = res;
        }
        dp[x][y] |= (1 << i);
        board[x][y] = i;
        vis[i]++;
        dfs(curr + 1);
        dp[x][y] = 0;
        board[x][y] = 0;
        vis[i]--;
        if (!vis[i]) {
          sum = (res - pre) % mod;
        }
      }
    }
  } else {
    dp[x][y] = z;
    if (!(dp[x][y] & (1 << board[x][y]))) {
      dp[x][y] |= (1 << board[x][y]);
      dfs(curr + 1);
    }
  }
}
int main() {
  cin >> n >> m >> k;
  if (m + n - 1 > k) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> board[i][j];
      if (board[i][j]) vis[board[i][j]]++;
    }
  }
  dfs(0);
  cout << res << endl;
}
