#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int mod = 1000000000 + 7;
int n;
int m;
int k;
int g[11][11];
int u[11][11];
int w[11];
int p[11];
int q[11];
int c[11][11];
int f[11];
int r[11];
int go(int i, int j, int K) {
  if (i == n) {
    j++;
    i = 0;
  }
  if (j == m) {
    for (int i = 0; i < k; i++) {
      p[i] = -1;
      q[i] = 0;
      r[i] = -1;
    }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        q[u[i][j]] = 1;
        if (g[i][j] != -1) {
          if (p[u[i][j]] != -1 && p[u[i][j]] != g[i][j]) return 0;
          if (r[g[i][j]] != -1 && r[g[i][j]] != u[i][j]) return 0;
          p[u[i][j]] = g[i][j];
          r[g[i][j]] = u[i][j];
        }
      }
    int a = 0, b = 0;
    for (int i = 0; i < k; i++) {
      a += int(q[i] == 1 && p[i] == -1);
      b += int(p[i] == -1);
    }
    return ((long long)c[b][a] * f[a]) % mod;
  }
  int ans = 0;
  for (int t = 0; t < K; t++)
    if (w[t] > i) {
      int tmp = w[t];
      w[t] = i;
      u[i][j] = t;
      (ans += go(i + 1, j, min(k, K + int(t + 1 == K)))) %= mod;
      w[t] = tmp;
    }
  return ans;
}
int main() {
  f[0] = 1;
  for (int i = 1; i <= 10; i++) f[i] = f[i - 1] * i;
  for (int i = 0; i <= 10; i++)
    for (int j = 0; j <= i; j++)
      if (i == 0 || j % i == 0)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf("%d", &g[i][j]);
      g[i][j]--;
    }
  for (int i = 0; i < k; i++) w[i] = n;
  cout << go(0, 0, 1) << endl;
  return 0;
}
