#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
inline long long read(long long x = 0) { return scanf("%lld", &x), x; }
long long n, m, a[11][11], K, f[11][11], vis[11];
inline long long get_num(long long x, long long res = 0) {
  for (; x; x -= (x & -x)) res++;
  return res;
}
long long dfs(long long x, long long y) {
  if (x == n + 1) return 1;
  long long now = 0, px, py, res = 0;
  if (y == m) {
    px = x + 1, py = 1;
  } else {
    px = x, py = y + 1;
  }
  f[x][y] = f[x][y - 1];
  for (register long long i = 1; i <= x; ++i) now |= f[i][y];
  long long cnt = get_num(now);
  if (K - cnt < (n - x) + (n - y) + 1) return 0;
  if (a[x][y]) {
    if (now & (1 << a[x][y] - 1))
      return 0;
    else {
      long long pre = f[x][y];
      f[x][y] |= (1 << a[x][y] - 1);
      res = dfs(px, py);
      f[x][y] = pre;
    }
  } else {
    long long tmp = 0, pre, num = 0;
    for (register long long i = 1; i <= K; ++i) {
      if (now & (1 << i - 1)) continue;
      if (!vis[i]) {
        num++;
        if (num == 1) {
          pre = f[x][y];
          f[x][y] |= (1 << i - 1);
          vis[i]++;
          tmp = dfs(px, py);
          f[x][y] = pre, vis[i]--;
        }
      } else {
        pre = f[x][y];
        f[x][y] |= (1 << i - 1);
        vis[i]++;
        res += dfs(px, py);
        f[x][y] = pre, vis[i]--;
      }
    }
    res += num * tmp % mod;
    res %= mod;
  }
  return res % mod;
}
signed main() {
  n = read(), m = read(), K = read();
  if (n + m - 1 > K) return puts("0"), 0;
  for (register long long i = 1; i <= n; ++i) {
    for (register long long j = 1; j <= m; ++j) {
      a[i][j] = read();
      if (a[i][j]) vis[a[i][j]]++;
    }
  }
  long long ans = dfs(1, 1);
  cout << ans << '\n';
  return 0;
}
