#include <bits/stdc++.h>
int n, m, k, mp[15][15], qg[15][15], flag[15];
inline bool check(int x, int y) {
  int tmp = qg[x][y], _tmp = 0;
  while (tmp) {
    _tmp += tmp & 1;
    tmp >>= 1;
  }
  return k - _tmp >= m + n - x - y;
}
int dfs(int x, int y) {
  int tmp = 0, po = 0, sum = 0;
  qg[x][y] = qg[x - 1][y] | qg[x][y - 1];
  if (x > n) return 1;
  if (!check(x, y)) return 0;
  if (mp[x][y]) {
    if (qg[x][y] & (1 << mp[x][y])) return 0;
    qg[x][y] |= 1 << mp[x][y];
    if (y == m)
      return dfs(x + 1, 1);
    else
      return dfs(x, y + 1);
  }
  for (register int i = 1, _ = 2; i <= k; ++i, _ <<= 1)
    if (!(_ & qg[x][y])) {
      if (flag[i]) {
        qg[x][y] |= _;
        if (y == m)
          sum += dfs(x + 1, 1);
        else
          sum += dfs(x, y + 1);
        sum %= 1000000007;
        qg[x][y] ^= _;
        continue;
      }
      if (!tmp) {
        qg[x][y] |= _;
        flag[i] = 1;
        tmp = 1;
        if (y == m)
          po = dfs(x + 1, 1);
        else
          po = dfs(x, y + 1);
        qg[x][y] ^= _;
        flag[i] = 0;
      }
      sum += po;
      sum %= 1000000007;
    }
  return sum % 1000000007;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    printf("0");
    return 0;
  }
  for (register int i = 1; i <= n; ++i)
    for (register int j = 1; j <= m; ++j) {
      scanf("%d", &mp[i][j]);
      flag[mp[i][j]] = 1;
    }
  printf("%d", dfs(1, 1));
  return 0;
}
