#include <bits/stdc++.h>
int n, m, k, lg[1 << 11], g[11][11], used[11], vis[11][11];
inline int read() {
  int f = 1, ch = getchar(), x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int dfs(int x, int y) {
  if (y > m) x++, y = 1;
  if (x > n) return 1;
  int cnt = 0, w = -1, cc = vis[x - 1][y] | vis[x][y - 1];
  for (int i = (~cc) & ((1 << k) - 1); i; i -= (i & (-i))) {
    int nm = lg[i & (-i)] + 1;
    if (!g[x][y] || g[x][y] == nm) {
      vis[x][y] = cc | (1 << (nm - 1));
      used[nm]++;
      if (used[nm] == 1) {
        if (w == -1) w = dfs(x, y + 1);
        cnt += w;
      } else if (used[nm])
        cnt += dfs(x, y + 1);
      cnt %= 1000000007;
      used[nm]--;
    }
  }
  return cnt;
}
int main() {
  n = read();
  m = read();
  k = read();
  if (k < n + m - 1) {
    printf("0");
    return 0;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      g[i][j] = read();
      ++used[g[i][j]];
    }
  for (int i = 0; i <= 10; ++i) lg[1 << i] = i;
  printf("%d", dfs(1, 1));
  return 0;
}
