#include <bits/stdc++.h>
using namespace std;
int getint() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
long long fac[1000], inv[1000];
void init(int N) {
  fac[0] = inv[0] = fac[1] = inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    fac[i] = (fac[i - 1] * i) % 1000000007;
    inv[i] = ((1000000007 - 1000000007 / i) * inv[1000000007 % i] % 1000000007);
  }
  for (int i = 1; i <= N; i++) inv[i] = (inv[i - 1] * inv[i]) % 1000000007;
  return;
}
int answer = 0;
long long A(int x, int y) { return (fac[x] * inv[x - y]) % 1000000007; }
int n, m, k;
int mp[15][15];
int b[15][15];
int a[15][15];
int ex[15];
int p[15];
int calc() {
  memset(ex, 0, sizeof(ex));
  memset(p, 0, sizeof(p));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) ex[a[i][j]] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (mp[i][j]) {
        if (p[a[i][j]] != 0 && p[a[i][j]] != mp[i][j])
          return 0;
        else
          p[a[i][j]] = mp[i][j];
      }
    }
  for (int i = 1; i <= k; i++)
    if (p[i])
      for (int j = i + 1; j <= k; j++)
        if (p[i] == p[j]) return 0;
  int sum = k, used = 0;
  for (int i = 1; i <= k; i++)
    if (p[i]) sum--;
  for (int i = 1; i <= k; i++)
    if (!p[i] && ex[i]) used++;
  return A(sum, used);
}
bool check(int x, int y) {
  b[x][y] = 0 | b[x - 1][y] | b[x][y - 1];
  if ((1 << a[x][y]) & b[x][y])
    return false;
  else {
    b[x][y] |= (1 << a[x][y]);
    return true;
  }
}
int dfs(int x, int y, int used) {
  if (x == n + 1) return calc();
  if (y == m + 1) return dfs(x + 1, 1, used);
  int res = 0;
  for (int i = 1; i <= k; i++) {
    if (i > used + 1) break;
    a[x][y] = i;
    if (check(x, y)) {
      res += dfs(x, y + 1, max(used, i));
      while (res >= 1000000007) res -= 1000000007;
    }
    a[x][y] = 0;
  }
  return res;
}
int main() {
  n = getint(), m = getint(), k = getint();
  init(20);
  if (n + m - 1 > k) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) mp[i][j] = getint();
  int ans = dfs(1, 1, 0);
  printf("%d\n", ans);
  return 0;
}
