#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  short negative = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') negative = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  x *= negative;
}
long long quickpower(long long n, long long k) {
  long long ans = 1;
  while (k) {
    if (k % 2) {
      ans *= n;
      ans %= 1000000007;
    }
    n *= n;
    n %= 1000000007;
    k /= 2;
  }
  return ans;
}
string int_to_string(int n) {
  string s = "";
  while (n) {
    int now = n % 10;
    s += now + '0';
    n /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
int string_to_int(string s) {
  int n = 0;
  for (int i = 0, _n = s.size(); i < s.size(); i++) {
    n *= 10;
    n += s[i] - '0';
  }
  return n;
}
int n, m, k;
int a[11][11];
int col[11][11];
int mask[11][11];
int p[11];
long long ans;
bool ex[11];
long long count() {
  for (int i = 0, _n = k; i < k; i++) p[i] = -1;
  for (int i = 0, _n = k; i < k; i++) ex[i] = 0;
  for (int i = 0, _n = n; i < n; i++)
    for (int j = 0, _n = m; j < m; j++)
      if (a[i][j] != -1) {
        int XZVJDFADSPFOE = a[i][j];
        int GASDIJSLDAEJF = col[i][j];
        if (p[GASDIJSLDAEJF] != -1 && p[GASDIJSLDAEJF] != XZVJDFADSPFOE)
          return 0;
        p[GASDIJSLDAEJF] = XZVJDFADSPFOE;
      }
  for (int i = 0, _n = n; i < n; i++)
    for (int j = 0, _n = m; j < m; j++) ex[col[i][j]] = 1;
  for (int i = 0, _n = k; i < k; i++)
    for (int j = 0, _n = i; j < i; j++)
      if (p[i] == p[j] && p[i] != -1) return 0;
  int cols = 0, have = k;
  for (int i = 0, _n = k; i < k; i++) {
    if (p[i] == -1 && ex[i]) cols++;
    if (p[i] != -1) have--;
  }
  long long cnt = 1;
  for (int i = 0, _n = cols; i < cols; i++) cnt *= (have - i) % 1000000007;
  return cnt;
}
bool check(int x, int y) {
  mask[x][y] = 0;
  if (x) mask[x][y] |= mask[x - 1][y];
  if (y) mask[x][y] |= mask[x][y - 1];
  if (mask[x][y] & (1 << col[x][y])) return 0;
  mask[x][y] |= (1 << col[x][y]);
  return 1;
}
void dfs(int x, int y, int c) {
  if (x == n) {
    ans += count() % 1000000007;
    return;
  }
  int xx = x, yy = y + 1;
  if (yy == m) {
    xx++;
    yy = 0;
  }
  for (int i = 0, _n = c + 1; i < c + 1; i++) {
    if (i < k) {
      col[x][y] = i;
      if (check(x, y)) {
        dfs(xx, yy, max(c, i + 1));
      }
      col[x][y] = -1;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  memset(mask, 0, sizeof(mask));
  memset(col, -1, sizeof(col));
  cin >> n >> m >> k;
  if (n + m - 1 > k) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0, _n = n; i < n; i++)
    for (int j = 0, _n = m; j < m; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  dfs(0, 0, 0);
  cout << ans % 1000000007 << endl;
  return 0;
}
