#include <bits/stdc++.h>
using namespace std;
const long long kMod = 1000000007;
int N, M, K;
int C[15][15];
int f[15][15], g[15][15];
long long res;
void read();
void soups_on();
void dfs(int, int, int);
void add_answer();
inline bool is_valid(int x, int y, int i) {
  int t = f[x - 1][y] | f[x][y - 1];
  return bool((t >> i & 1) ^ 1);
}
int main() {
  cin >> N >> M >> K;
  if (N + M - 1 > K)
    cout << "0\n";
  else {
    read();
    soups_on();
  }
  return 0;
}
void read() {
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) cin >> C[i][j];
}
void soups_on() {
  dfs(1, 1, 1);
  cout << res << "\n";
}
void dfs(int x, int y, int lim) {
  if (x == N + 1) {
    add_answer();
    return;
  }
  for (int i = 1; i <= lim; ++i)
    if (is_valid(x, y, i)) {
      f[x][y] = f[x - 1][y] | f[x][y - 1] | (1 << i);
      g[x][y] = i;
      dfs(y == M ? x + 1 : x, y == M ? 1 : y + 1, min(K, max(lim, i + 1)));
    }
}
void add_answer() {
  int mx[15], my[15], used_clr, fixed_clr;
  fill(&mx[0], &mx[15], 0);
  fill(&my[0], &my[15], 0);
  used_clr = 0;
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) {
      used_clr = max(used_clr, g[i][j]);
      if (C[i][j]) {
        if (mx[C[i][j]] && mx[C[i][j]] != g[i][j]) return;
        if (my[g[i][j]] && my[g[i][j]] != C[i][j]) return;
        mx[C[i][j]] = g[i][j], my[g[i][j]] = C[i][j];
      }
    }
  fixed_clr = count_if(mx, mx + 15, [](int i) { return i != 0; });
  long long t = 1;
  for (int i = 0; i < used_clr - fixed_clr; ++i)
    t = t * (K - fixed_clr - i) % kMod;
  res = (res + t) % kMod;
}
