#include <bits/stdc++.h>
using namespace std;
const int T = 1e9 + 7;
int a[20][20], b[20][20], n, m, k, g[20][20];
long long ans = 0;
bool check(int x, int y) {
  b[x][y] = b[x][y - 1] | b[x - 1][y];
  if (b[x][y] & (1 << a[x][y])) return 0;
  b[x][y] |= (1 << a[x][y]);
  return 1;
}
int p[20];
void cal() {
  memset(p, 0, sizeof(p));
  int A = k, B = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      B = max(B, a[i][j]);
      if (g[i][j]) {
        if (p[a[i][j]] && p[a[i][j]] != g[i][j])
          return;
        else
          p[a[i][j]] = g[i][j];
      }
    }
  for (int i = 1; i <= k; i++)
    if (p[i])
      for (int j = 1; j <= k; j++)
        if (i != j && p[i] == p[j]) return;
  for (int i = 1; i <= k; i++)
    if (p[i]) A--, B--;
  long long sum = 1;
  for (int i = A; i >= (A - B + 1); i--) sum *= i, sum %= T;
  ans += sum;
  ans %= T;
  return;
}
void dfs(int x, int y, int cur) {
  if (x == n + 1) {
    cal();
    return;
  }
  if (y == m + 1) {
    dfs(x + 1, 1, cur);
    return;
  }
  for (int i = 1; i <= cur; i++)
    if (i <= k) {
      a[x][y] = i;
      if (check(x, y)) dfs(x, y + 1, max(i + 1, cur));
    }
  return;
}
int main() {
  cin >> n >> m >> k;
  if (k < n + m - 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &g[i][j]);
  memset(b, 0, sizeof(b));
  dfs(1, 1, 1);
  cout << ans << endl;
  return 0;
}
