#include <bits/stdc++.h>
using namespace std;
int N, M, K, ans, a[15][15], f[15][15], S, F[15], b[15];
bool c[15][15][15];
void init() {
  scanf("%d%d%d", &N, &M, &K);
  if (N + M - 1 > K) puts("0"), exit(0);
  int t = 0;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++) {
      scanf("%d", &a[i][j]), a[i][j]--;
      if (a[i][j] >= 0 && !F[a[i][j]]) F[a[i][j]] = ++t;
    }
  S = K - t;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++)
      if (a[i][j] >= 0) a[i][j] = S + F[a[i][j]] - 1;
}
void dfs(int x, int y, int t) {
  if (t > S) return;
  if (y > M) x++, y = 1;
  if (x > N) {
    long long s = 1;
    for (int i = S; i > S - t; i--) s = s * i % 1000000007;
    (ans += s) %= 1000000007;
    return;
  }
  bool ok = 1;
  int w = f[x - 1][y] | f[x][y - 1];
  if (a[x][y] >= 0)
    if (!((w >> a[x][y]) & 1))
      f[x][y] = w | (1 << a[x][y]), dfs(x, y + 1, t);
    else
      ;
  else
    for (int i = 0; i < K; i++)
      if (!((w >> i) & 1) && (i <= t || (i >= S && !c[i][x][y])))
        f[x][y] = w | (1 << i), dfs(x, y + 1, t + (i == t));
}
void doit() {
  for (int k = S; k < K; k++)
    for (int i = N; i; i--)
      for (int j = M; j; j--)
        c[k][i][j] = c[k][i + 1][j] || c[k][i][j + 1] || (a[i][j] == k);
  dfs(1, 1, 0), printf("%d\n", ans);
}
int main() {
  init();
  doit();
  return 0;
}
