#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int maxn = 100;
int c[maxn][maxn];
int p[maxn][maxn];
bool cnt[maxn];
const int mod = 1e9 + 7;
int ans = 0;
bool pd[maxn];
void dfs(int x, int y, int s) {
  if (y == m + 1) {
    if (x == n) {
      ans += s;
      ans %= mod;
      return;
    }
    dfs(x + 1, 1, s);
    return;
  }
  if (c[x][y]) {
    bool fl = pd[c[x][y] - 1];
    pd[c[x][y] - 1] = 1;
    if (((p[x - 1][y] >> c[x][y] - 1) & 1) ||
        ((p[x][y - 1] >> c[x][y] - 1) & 1))
      return;
    p[x][y] = p[x - 1][y] | p[x][y - 1] | (1 << c[x][y] - 1);
    dfs(x, y + 1, s);
    if (!fl) pd[c[x][y] - 1] = 0;
    return;
  }
  bool fl = 0;
  int sum = 0;
  int rest = 0;
  for (int i = 0; i < k; i++) {
    if (((p[x - 1][y] >> i) & 1) || ((p[x][y - 1] >> i) & 1)) continue;
    rest++;
    if (!pd[i] && !cnt[i]) sum++;
  }
  if (rest < n - x + m - y + 1) return;
  for (int i = 0; i < k; i++) {
    if (((p[x - 1][y] >> i) & 1) || ((p[x][y - 1] >> i) & 1)) continue;
    p[x][y] = p[x - 1][y] | p[x][y - 1] | (1 << i);
    if (!pd[i] && !cnt[i]) {
      if (!fl) {
        pd[i] = 1;
        dfs(x, y + 1, s * sum);
        fl = 1;
        pd[i] = 0;
      }
    } else {
      bool flag = pd[i];
      pd[i] = 1;
      dfs(x, y + 1, s);
      if (!flag) pd[i] = 0;
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &c[i][j]);
      cnt[c[i][j] - 1] = 1;
    }
  dfs(1, 1, 1);
  printf("%d\n", ans);
  return 0;
}
