#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const int mod = 1000000007;
int mp[1010][1010];
int f[12][12];
int use[12];
int two[12];
int n, m, k;
int Log[1 << 12];
int dfs(int x, int y) {
  if (y == m + 1) {
    x++;
    if (x > n) return 1;
    y = 1;
  }
  int state = f[x - 1][y] | f[x][y - 1];
  int w = -1, sum = 0;
  for (int j = ~state & (two[k] - 1); j; j -= j & -j) {
    int who = Log[j & -j];
    if (!mp[x][y] || mp[x][y] == who + 1) {
      use[who + 1]++;
      f[x][y] = state | two[who];
      if (use[who + 1] == 1) {
        if (w == -1) w = dfs(x, y + 1);
        sum += w;
      } else if (use[who + 1]) {
        sum += dfs(x, y + 1);
      }
      if (sum >= mod) sum -= mod;
      use[who + 1]--;
    }
  }
  return sum;
}
int main() {
  two[0] = 1;
  Log[1] = 0;
  for (int i = 1; i <= 10; i++) two[i] = two[i - 1] * 2, Log[1 << i] = i;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &mp[i][j]);
      use[mp[i][j]]++;
    }
  }
  if (n + m - 1 > k) return puts("0"), 0;
  printf("%d\n", dfs(1, 1));
  return 0;
}
