#include <bits/stdc++.h>
int lowbit(int i) { return (i & (-i)); }
using namespace std;
const int N = 15;
const int Mo = 1000000007;
int n, m, k;
int f[N][N], col[N], LOG[1 << N], a[N][N];
int dfs(int x, int y) {
  if (y > m) x++, y = 1;
  if (x > n) return 1;
  int tmpf = f[x - 1][y] | f[x][y - 1];
  int first = -1, ans = 0;
  for (int i = (~tmpf) & ((1 << k) - 1); i; i -= lowbit(i)) {
    int tmp = LOG[lowbit(i)];
    if (a[x][y] == tmp || a[x][y] == 0) {
      col[tmp]++;
      f[x][y] = tmpf | (1 << (tmp - 1));
      if (col[tmp] == 1) {
        if (first == -1) first = dfs(x, y + 1) % Mo;
        ans = (ans + first) % Mo;
      } else
        ans = (ans + dfs(x, y + 1) % Mo) % Mo;
      col[tmp]--;
    }
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]), col[a[i][j]]++;
  for (int i = 1; i <= k + 1; i++) LOG[1 << (i - 1)] = i;
  printf("%d\n", dfs(1, 1));
  return 0;
}
