#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const long double EPS = 1e-12;
const int INF = 1e9 + 10;
const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100;
const int MOD = 1e9 + 7;
int n, m, k;
int lg[1 << 20], arr[20][20];
int f[20][20], chet[20];
int solve(int x, int y) {
  if (y == m + 1) y = 1, ++x;
  if (x == n + 1) return 1;
  int p = 0, w = -1, cur = f[x - 1][y] | f[x][y - 1];
  for (int i = (~cur) & ((1 << k) - 1); i; i ^= (i & (-i))) {
    int t = lg[i & (-i)] + 1;
    if (!arr[x][y] || arr[x][y] == t) {
      f[x][y] = cur | (1 << (t - 1)), ++chet[t];
      if (chet[t] == 1) {
        if (w == -1) w = solve(x, y + 1);
        p += w;
      } else if (chet[t]) {
        p += solve(x, y + 1);
      }
      if (p >= MOD) p -= MOD;
      chet[t]--;
    }
  }
  return p;
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  if (n + m - 1 > k) {
    for (int i = 0; i < n * m; ++i) {
      int t;
      cin >> t;
    }
    cout << 0 << '\n';
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> arr[i][j];
      chet[arr[i][j]]++;
    }
  }
  for (int i = 1; i <= k; i++) {
    lg[1 << i] = i;
  }
  cout << solve(1, 1) << '\n';
  return 0;
}
