#include <bits/stdc++.h>
using namespace std;
int Get() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = 0;
  while (c >= '0' && c <= '9') {
    X = X * 10 + c - 48;
    c = getchar();
  }
  return X;
}
const int Mod = 1000000007;
int M, N, K;
int A[10][10];
bool Flag[10];
long long DFS(int X, int Y) {
  if (Y == N) return DFS(X + 1, 0);
  if (X == M) return 1;
  bool Bad[10];
  memset(Bad, 0, sizeof(Bad));
  for (int i = 0; i <= X; i++)
    for (int j = 0; j <= Y; j++)
      if ((i < X || j < Y) && (A[i][j] != -1)) Bad[A[i][j]] = true;
  for (int i = X; i < M; i++)
    for (int j = Y; j < N; j++)
      if ((i > X || j > Y) && (A[i][j] != -1)) Bad[A[i][j]] = true;
  long long Ans = 0;
  for (int i = 0; i < K; i++)
    if (Flag[i] && !Bad[i]) {
      if (A[X][Y] != -1 && A[X][Y] != i) continue;
      int T = A[X][Y];
      A[X][Y] = i;
      Ans = (Ans + DFS(X, Y + 1)) % Mod;
      A[X][Y] = T;
    }
  int Count = 0, Color = -1;
  for (int i = 0; i < K; i++)
    if (!Flag[i]) {
      Count++;
      Color = i;
    }
  if (A[X][Y] == -1 && Count) {
    A[X][Y] = Color;
    Flag[Color] = true;
    Ans = (Ans + DFS(X, Y + 1) * Count) % Mod;
    A[X][Y] = -1;
    Flag[Color] = false;
  }
  return Ans;
}
int main() {
  M = Get();
  N = Get();
  K = Get();
  if (M + N - 1 > K) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < M; i++)
    for (int j = 0; j < N; j++) A[i][j] = Get() - 1;
  memset(Flag, 0, sizeof(Flag));
  for (int i = 0; i < M; i++)
    for (int j = 0; j < N; j++)
      if (A[i][j] != -1) Flag[A[i][j]] = true;
  cout << DFS(0, 0) << endl;
  return 0;
}
