#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int mod = 1000000007;
int n, m, K;
int ans;
int f[1005];
int a[15][15];
int s[15][15];
bool vis[1005];
void dfs(int x, int y, int tot) {
  if (tot > K) return;
  if (y == m + 1) {
    x++;
    y = 1;
  }
  if (x == n + 1) {
    int num = 0;
    int res = 1;
    for (int i = 1; i <= K; i++) {
      if (f[i]) num++;
    }
    for (int i = K - tot + 1; i <= K - num; i++) {
      res *= i;
    }
    ans = (ans + res) % mod;
    return;
  }
  s[x][y] = s[x - 1][y] | s[x][y - 1];
  if (a[x][y]) {
    if (f[a[x][y]]) {
      if ((s[x][y] >> f[a[x][y]]) & 1) {
        return;
      }
      s[x][y] |= 1 << f[a[x][y]];
      dfs(x, y + 1, tot);
    } else {
      for (int i = 1; i <= tot + 1; ++i) {
        if (((s[x][y] >> i) & 1) == 0 and !vis[i]) {
          s[x][y] ^= 1 << i;
          f[a[x][y]] = i;
          vis[i] = 1;
          dfs(x, y + 1, max(i, tot));
          s[x][y] ^= 1 << i;
          f[a[x][y]] = 0;
          vis[i] = 0;
        }
      }
    }
    return;
  }
  for (int i = 1; i <= tot + 1; i++) {
    if (((s[x][y] >> i) & 1) == 0) {
      s[x][y] ^= 1 << i;
      dfs(x, y + 1, max(i, tot));
      s[x][y] ^= 1 << i;
    }
  }
}
int main() {
  cin >> n >> m >> K;
  if (n + m - 1 > K) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  dfs(1, 1, 0);
  cout << ans;
  return 0;
}
