#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m, k;
int a[11][11];
int f[11][11];
int cnt[21];
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writern(long long x) { write(x), putchar(' '); }
void writeln(long long x) { write(x), puts(""); }
long long dfs(int x, int y) {
  if (y > m) {
    y = 1, x++;
  }
  if (x > n) return 1;
  long long res = 0;
  int s = f[x - 1][y] | f[x][y - 1];
  int cc = 0, flag = -1;
  for (int i = s; i; i -= (i & -i)) cc++;
  if (m + n - x - y + 1 > k - cc) return 0;
  for (int i = s ^ ((1 << k) - 1); i; i -= (i & -i)) {
    int t = i & (-i);
    int tt = log2(t) + 1;
    if (a[x][y] == 0 || a[x][y] == tt) {
      f[x][y] = s | t;
      cnt[tt]++;
      if (cnt[tt] == 1) {
        if (flag == -1) flag = dfs(x, y + 1);
        res += flag;
      } else if (cnt[tt])
        res += dfs(x, y + 1);
      res %= mod;
      cnt[tt]--;
    }
  }
  return res;
}
int main() {
  n = read(), m = read();
  k = read();
  if (n + m - 1 > k) {
    writeln(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]) cnt[a[i][j]]++;
    }
  writeln(dfs(1, 1) % mod);
  return 0;
}
