#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
template <typename T>
inline T Abs(T x) {
  return (x >= 0) ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline string toStr(T x) {
  stringstream st;
  st << x;
  string s;
  st >> s;
  return s;
}
template <typename T>
inline int bit(T mask, int b) {
  return (b >= 0 && (mask & (T(1) << b)) != 0) ? 1 : 0;
}
inline int nextInt() {
  int x;
  if (scanf("%d", &x) != 1) throw;
  return x;
}
inline long long nextInt64() {
  long long x;
  if (scanf("%I64d", &x) != 1) throw;
  return x;
}
inline double nextDouble() {
  double x;
  if (scanf("%lf", &x) != 1) throw;
  return x;
}
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 1100;
const int MOD = INF + 7;
int n, m, k, a[MAXN][MAXN], s[MAXN][MAXN], res[MAXN][MAXN];
int orcolor[MAXN], mycolor[MAXN];
int f[MAXN], c[MAXN][MAXN];
int C(int n, int k) {
  if (n == k || k == 0) return 1;
  int &ans = c[n][k];
  if (ans == -1) ans = (C(n - 1, k) + C(n - 1, k - 1)) % MOD;
  return ans;
}
int get(int x, int y, int c, int c1) {
  if (c > k) return 0;
  if (x == n) return (1LL * C(k - c1, c - c1) * f[c - c1]) % MOD;
  if (y == m) return get(x + 1, 0, c, c1);
  int mask = 0;
  if (x > 0) mask |= s[x - 1][y];
  if (y > 0) mask |= s[x][y - 1];
  int ans = 0;
  for (int i = 0; i < (int)(c + 1); i++) {
    if (bit(mask, i)) continue;
    int need = a[x][y];
    if (need == -1) {
      res[x][y] = i;
      s[x][y] = mask | (1 << i);
      ans = (ans + get(x, y + 1, max(c, i + 1), c1)) % MOD;
      continue;
    }
    if (mycolor[need] != -1 && mycolor[need] != i) continue;
    if (orcolor[i] != -1 && orcolor[i] != need) continue;
    if (mycolor[need] == -1) {
      mycolor[need] = i;
      orcolor[i] = need;
      res[x][y] = i;
      s[x][y] = mask | (1 << i);
      ans = (ans + get(x, y + 1, max(c, i + 1), c1 + 1)) % MOD;
      mycolor[need] = -1;
      orcolor[i] = -1;
    } else {
      res[x][y] = i;
      s[x][y] = mask | (1 << i);
      ans = (ans + get(x, y + 1, max(c, i + 1), c1)) % MOD;
    }
  }
  return ans;
}
int main() {
  n = nextInt();
  m = nextInt();
  k = nextInt();
  if (n + m - 1 > k) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(k + 1); i++)
    f[i] = (i == 0) ? 1 : (1LL * f[i - 1] * i) % MOD;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) a[i][j] = nextInt() - 1;
  memset(c, 255, sizeof c);
  memset(orcolor, 255, sizeof orcolor);
  memset(mycolor, 255, sizeof mycolor);
  cout << get(0, 0, 0, 0) << endl;
  return 0;
}
