#include <bits/stdc++.h>
using namespace std;
const int maxn = 10 + 2, MOD = 1000000000 + 7;
int n, m, K, a[maxn][maxn], p[maxn], ause[maxn], F[maxn][maxn], num[maxn][maxn];
long long ans;
void check() {
  memset(p, 0, sizeof(p));
  memset(ause, 0, sizeof(ause));
  int color = 0, Kc = K;
  for (int i = 1; i <= K; i++)
    if (((((F[n][m]) & (1 << (i - 1))) == 0) ? 0 : 1)) color++;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j]) {
        if ((ause[a[i][j]]) && (num[i][j] != ause[a[i][j]])) return;
        if ((p[num[i][j]]) && (p[num[i][j]] != a[i][j])) return;
        if ((ause[a[i][j]]) || (p[num[i][j]])) continue;
        p[num[i][j]] = a[i][j];
        ause[a[i][j]] = num[i][j];
        Kc--;
      }
  for (int i = 1; i <= K; i++)
    if (p[i]) color--;
  long long k = 1;
  for (int i = Kc; i >= Kc - color + 1; i--) k = (k * i) % MOD;
  ans += k;
  if (ans > MOD) ans -= MOD;
}
void search(int x, int y, int maxc) {
  if (x == (n + 1)) {
    check();
    return;
  }
  F[x][y] = F[x - 1][y] | F[x][y - 1];
  for (int i = 1; i <= maxc; i++)
    if (!((((F[x][y]) & (1 << (i - 1))) == 0) ? 0 : 1)) {
      num[x][y] = i, F[x][y] ^= (1 << (i - 1));
      if (y == m)
        search(x + 1, 1, min(K, max(i + 1, maxc)));
      else
        search(x, y + 1, min(K, max(i + 1, maxc)));
      num[x][y] = 0, F[x][y] ^= (1 << (i - 1));
    }
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  if ((n + m - 1) > K) {
    printf("%d\n", 0);
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  search(1, 1, 1);
  printf("%I64d\n", ans);
  return 0;
}
