#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 12;
int n, m, k;
int a[N][N], num[N], f[N][N];
inline int read() {
  char c;
  c = getchar();
  int ret = 0, b = 1;
  while (!(c >= '0' && c <= '9')) {
    if (c == '-') b = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ret = (c - '0') + (ret << 1) + (ret << 3);
    c = getchar();
  }
  return ret * b;
}
int DFS(int, int);
int main() {
  ios::sync_with_stdio(false);
  n = read();
  m = read();
  k = read();
  if (n + m - 1 > k) {
    cout << "0" << endl;
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      a[i][j] = read();
      if (a[i][j]) ++num[a[i][j]];
    }
  }
  cout << DFS(1, 1) % mod;
  return 0;
}
int DFS(int x, int y) {
  if (y == m + 1) {
    y = 1;
    ++x;
  }
  if (x == n + 1) return 1;
  int ret = 0, c = 0, now = f[x - 1][y] | f[x][y - 1];
  for (int i = now; i; i -= i & (-i)) ++c;
  if (m + n - x - y + 1 > k - c) return 0;
  int d = -1;
  int can = (~now) & ((1 << k) - 1);
  for (int i = can; i; i -= i & (-i)) {
    int temp = i & (-i);
    int t = log(temp + 0.5) / log(2) + 1;
    if (a[x][y] == 0 || a[x][y] == t) {
      f[x][y] = now | temp;
      ++num[t];
      if (num[t] == 1) {
        if (d == -1) d = DFS(x, y + 1);
        ret += d;
      } else if (num[t])
        ret += DFS(x, y + 1);
      ret %= mod;
      --num[t];
    }
  }
  return ret;
}
