#include <bits/stdc++.h>
const int N = 29;
const int K = 10;
const int MOD = 1e9 + 7;
int n, m, k;
int g[N][N];
int s[N][N][K];
int state[N][N];
int f[N];
bool ch[N];
int fac[N];
int inv[N];
int ans;
inline void init() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    puts("0");
    exit(0);
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) scanf("%d", &g[i][j]);
}
inline int pow_mod(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD, b >>= 1;
  }
  return ret;
}
inline int P(int n, int m) { return 1ll * fac[n] * inv[n - m] % MOD; }
void dfs(int x, int y, int tot, int tot2) {
  if (tot > k) return;
  if (y == m + 1) x++, y = 1;
  if (x == n + 1) {
    ans = (ans + P(k - tot2, tot - tot2)) % MOD;
    return;
  }
  state[x][y] = state[x - 1][y] | state[x][y - 1];
  if (g[x][y]) {
    if (f[g[x][y]]) {
      if (((state[x][y] >> (f[g[x][y]] - 1)) & 1)) return;
      state[x][y] ^= (1 << (f[g[x][y]] - 1));
      dfs(x, y + 1, tot, tot2);
      state[x][y] ^= (1 << (f[g[x][y]] - 1));
    } else {
      for (int i = 1; i <= tot + 1; ++i)
        if (!((state[x][y] >> (i - 1)) & 1) && !ch[i]) {
          state[x][y] ^= (1 << (i - 1));
          f[g[x][y]] = i, ch[i] = true;
          dfs(x, y + 1, std::max(i, tot), tot2 + 1);
          f[g[x][y]] = 0, ch[i] = false;
          state[x][y] ^= (1 << (i - 1));
        }
    }
  } else {
    for (int i = 1; i <= tot + 1; ++i)
      if (!((state[x][y] >> (i - 1)) & 1)) {
        state[x][y] ^= (1 << (i - 1));
        dfs(x, y + 1, std::max(i, tot), tot2);
        state[x][y] ^= (1 << (i - 1));
      }
  }
}
inline void solve() {
  fac[0] = inv[0] = 1;
  for (int i = 1; i <= k; ++i) {
    fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[i] = 1ll * inv[i - 1] * pow_mod(i, MOD - 2) % MOD;
  }
  memset(s, 0, sizeof s);
  dfs(1, 1, 0, 0);
  std::cout << ans << std::endl;
}
int main() {
  init();
  solve();
  return 0;
}
