#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c;
  int res = 0;
  while (!(c >= '0' && c <= '9')) c = getchar();
  while (c >= '0' && c <= '9') {
    res = (c - '0') + (res << 1) + (res << 3);
    c = getchar();
  }
  return res;
}
int m, n, k;
int a[15][15], num[15], f[15][15];
int dfs(int x, int y) {
  if (y == m + 1) {
    y = 1;
    x++;
  }
  if (x == n + 1) return 1;
  int res = 0, d = -1, now = f[x - 1][y] | f[x][y - 1], c = 0;
  for (int i = now; i; i -= i & (-i)) c++;
  if (m + n - x - y + 1 > k - c) return 0;
  int can = (~now) & ((1 << k) - 1);
  for (int i = can; i; i -= i & (-i)) {
    int tmp = i & (-i);
    int t = log(tmp + 0.5) / log(2) + 1;
    if (a[x][y] == 0 || a[x][y] == t) {
      f[x][y] = now | tmp;
      num[t]++;
      if (num[t] == 1) {
        if (d == -1) d = dfs(x, y + 1);
        res += d;
      } else if (num[t])
        res += dfs(x, y + 1);
      res %= 1000000007;
      num[t]--;
    }
  }
  return res;
}
int main() {
  n = read(), m = read(), k = read();
  if (n + m - 1 > k) {
    cout << '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]) num[a[i][j]]++;
    }
  cout << dfs(1, 1) % 1000000007;
  return 0;
}
