#include <bits/stdc++.h>
const int MOD = 1000000007;
int Free, n, m, K, ans, s[20][20], m1[20], m2[20], a[20][20];
int P(int n, int k) {
  int res = 1;
  for (int i = 2; i <= n; ++i) res *= i;
  for (int i = 2; i <= n - k; ++i) res /= i;
  return res;
}
void dfs(int x, int y, int tot) {
  if (tot > K) return;
  if (y > m) ++x, y = 1;
  if (x > n) {
    Free = 0;
    for (int i = 1; i <= tot; ++i) Free += !m1[i];
    (ans += P(K - (tot - Free), Free)) %= MOD;
    return;
  }
  s[x][y] = s[x - 1][y] | s[x][y - 1];
  if (a[x][y]) {
    int z = a[x][y];
    if (m2[z]) {
      if (s[x][y] >> m2[z] & 1) return;
      s[x][y] ^= 1 << m2[z];
      dfs(x, y + 1, tot);
      s[x][y] ^= 1 << m2[z];
    } else
      for (int i = 1; i <= tot + 1; ++i)
        if (!(s[x][y] >> i & 1) && !m1[i]) {
          s[x][y] ^= 1 << i;
          m1[m2[z] = i] = z;
          dfs(x, y + 1, std::max(tot, i));
          s[x][y] ^= 1 << i;
          m2[z] = m1[i] = 0;
        }
  } else
    for (int i = 1; i <= tot + 1; ++i)
      if (!(s[x][y] >> i & 1)) {
        s[x][y] ^= 1 << i;
        dfs(x, y + 1, std::max(tot, i));
        s[x][y] ^= 1 << i;
      }
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  if (n + m - 1 > K) return puts("0");
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) scanf("%d", &a[i][j]);
  dfs(1, 1, 0);
  printf("%d\n", ans);
}
