#include <bits/stdc++.h>
using namespace std;
const int N = 15, M = 1e9 + 7;
int read(int x = 0, int f = 1, char c = getchar()) {
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
int n, m, k, a[N][N], b[N], f[N][N];
int Cal(int s, int ans = 0) {
  for (; s; s -= s & -s) ans++;
  return ans;
}
int Dfs(int x, int y) {
  y == m ? x++, y = 1 : y++;
  if (x > n) return 1;
  int s = f[x - 1][y] | f[x][y - 1], tmp = -1, ans = 0;
  if (k - Cal(s) < n - x + m - y + 1) return 0;
  for (int i = 1; i <= k; ++i) {
    if ((s & 1 << i - 1) || (a[x][y] && a[x][y] != i)) continue;
    f[x][y] = s | (1 << i - 1);
    if (!b[i]++)
      ans = (ans + (tmp == -1 ? tmp = Dfs(x, y) : tmp)) % M;
    else
      ans = (ans + Dfs(x, y)) % M;
    b[i]--;
  }
  return ans;
}
int main() {
  n = read(), m = read(), k = read();
  if (n + m - 1 > k) return puts("0"), 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) a[i][j] = read(), b[a[i][j]]++;
  printf("%d\n", Dfs(1, 0));
  return 0;
}
