#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[2000010];
  scanf("%s", ch);
  return ch;
}
const int MAX_LG = 21;
const long long maxn = 1e6 + 10;
const long long maxm = 3e5 + 10;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e12 + 100;
long long n, m, k;
long long a[20][20];
long long mini[20];
long long res;
long long cnt[20];
long long fact[20];
long long arr[20][20];
bool saw[20];
long long tot = 0;
long long mp[20], mp2[20];
inline void recursion(long long row, long long col) {
  if (row == n) {
    memset(mp, 0, sizeof mp);
    memset(mp2, 0, sizeof mp2);
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (arr[i][j] == 0) continue;
        if (mp[arr[i][j]]) {
          if (mp[arr[i][j]] != a[i][j]) return;
        } else {
          mp[arr[i][j]] = a[i][j];
        }
        if (mp2[a[i][j]]) {
          if (mp2[a[i][j]] != arr[i][j]) return;
        } else {
          mp2[a[i][j]] = arr[i][j];
        }
      }
    }
    long long cur = 1;
    while (cur < k && cnt[cur + 1]) cur++;
    res += fact[k - tot] / fact[k - cur];
    if (res >= mod) res -= mod;
    return;
  }
  for (long long i = 1; i <= k && cnt[i - 1]; i++) {
    if (mini[i] > col) {
      long long was = mini[i];
      cnt[i]++;
      mini[i] = col;
      a[row][col] = i;
      recursion(row + bool(col == m - 1), (col + 1) % m);
      mini[i] = was;
      cnt[i]--;
    }
  }
}
int32_t main() {
  n = in(), m = in(), k = in();
  if (n + m - 1 > k) return cout << 0 << "\n", 0;
  for (long long i = 0; i <= k; i++) mini[i] = INF;
  fact[0] = 1;
  cnt[0]++;
  mini[0] = 0;
  saw[0] = true;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      arr[i][j] = in();
      if (!saw[arr[i][j]]) {
        saw[arr[i][j]] = true;
        tot++;
      }
    }
  }
  for (long long i = 1; i < 20; i++) fact[i] = i * fact[i - 1];
  recursion(0, 0);
  cout << res << "\n";
}
