#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5, INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int A[12][12], visit[12], F[12][12];
long long ans;
int n, m, k;
void dfs(int x, int y) {
  if (x == (n + 1)) {
    ans++;
    return;
  }
  F[x][y] = F[x - 1][y] | F[x][y - 1];
  int p = 1, q = k, c = 0;
  for (int i = 1; i <= k; ++i) {
    if (((((F[x][y]) & (1 << (i - 1))) == 0) ? 0 : 1)) c++;
  }
  if ((n - x) + (m - y) + 1 > k - c) return;
  long long sum = -1, pre;
  if (A[x][y] > 0) p = q = A[x][y];
  for (int i = p; i <= q; ++i) {
    if (!((((F[x][y]) & (1 << (i - 1))) == 0) ? 0 : 1)) {
      if (!visit[i]) {
        if (sum >= 0) {
          ans += sum;
          if (ans > mod) ans -= mod;
          continue;
        }
        pre = ans;
      }
      F[x][y] ^= (1 << (i - 1));
      visit[i]++;
      if (y == m)
        dfs(x + 1, 1);
      else
        dfs(x, y + 1);
      F[x][y] ^= (1 << (i - 1));
      visit[i]--;
      if (!visit[i]) sum = (ans - pre) % mod;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  if (n + m - 1 > k) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> A[i][j];
      if (A[i][j]) visit[A[i][j]]++;
    }
  }
  ans = 0;
  dfs(1, 1);
  cout << ans % mod << endl;
  return 0;
}
