#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
inline int read() {
  int x = 0, neg = 1;
  char op = getchar();
  while (!isdigit(op)) {
    if (op == '-') neg = -1;
    op = getchar();
  }
  while (isdigit(op)) {
    x = 10 * x + op - '0';
    op = getchar();
  }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 15;
const int mod = 1e9 + 7;
int bit[1024], n, m, k;
int a[N][N], col[N];
int f[N][N];
int dfs(int x, int y) {
  if (y == m + 1) x++, y = 1;
  if (x == n + 1) {
    return 1;
  }
  int statu = f[x - 1][y] | f[x][y - 1], same = -1, ret = 0;
  int rev = ~statu & ((1 << k) - 1);
  if (n - x + m - y + 1 > bit[rev]) {
    return 0;
  }
  for (register int i = 0; i < k; i++)
    if (rev & 1 << i) {
      if (!a[x][y] || a[x][y] == i + 1) {
        col[i + 1]++;
        f[x][y] = statu | 1 << i;
        if (col[i + 1] == 1) {
          if (same == -1) same = dfs(x, y + 1);
          ret += same;
        } else {
          ret += dfs(x, y + 1);
        }
        if (ret >= mod) ret -= mod;
        col[i + 1]--;
      }
    }
  return ret;
}
int main() {
  n = read(), m = read(), k = read();
  if (n + m - 1 > k) {
    puts("0");
    exit(0);
  }
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= m; j++) a[i][j] = read(), col[a[i][j]]++;
  for (register int i = 0; i <= 1023; i++) bit[i] = bit[i >> 1] + (i & 1);
  printf("%d\n", dfs(1, 1));
  return 0;
}
