#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
int A[15][15], f[15][15], use[15];
int n, m, k;
int dfs(int x, int y) {
  if (x > n) return 1;
  int s = -1, now = f[x - 1][y] | f[x][y - 1];
  int res = 0, cnt = 0;
  for (int i = 0; i < k; i++)
    if (now & (1 << i)) cnt++;
  if ((n - x) + (m - y) + 1 > (k - cnt)) return 0;
  if (A[x][y] && now & (1 << A[x][y] - 1)) return 0;
  for (int i = 1; i <= k; i++) {
    if (now & (1 << i - 1)) continue;
    if (!A[x][y] || A[x][y] == i) {
      f[x][y] = now | (1 << i - 1);
      if (!use[i] && s >= 0) {
        res += s;
        if (res >= 1000000007) res -= 1000000007;
        continue;
      }
      use[i]++;
      int tmp;
      if (y == m)
        tmp = dfs(x + 1, 1);
      else
        tmp = dfs(x, y + 1);
      use[i]--;
      res += tmp;
      if (res >= 1000000007) res -= 1000000007;
      if (!use[i]) s = tmp;
    }
  }
  return res;
}
int main() {
  n = read(), m = read(), k = read();
  if (n + m - 1 > k) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      A[i][j] = read();
      if (A[i][j]) use[A[i][j]]++;
    }
  printf("%d\n", dfs(1, 1));
  return 0;
}
