#include <bits/stdc++.h>
using namespace std;
const int mo = 1000000007;
int n, m, k, a[20][20], f[20][1010], bz[20];
int dfs(int x, int y) {
  if (y > m) x++, y = 1;
  if (x > n) return 1;
  int ans = 0, flow, s = 0;
  bool bj = false;
  f[x][y] = f[x - 1][y] | f[x][y - 1];
  for (int i = 1; i <= k; i++)
    if (f[x][y] & (1 << (i - 1))) s++;
  if (n + m - x - y + 1 > k - s) return 0;
  s = f[x][y];
  if (a[x][y]) {
    if (!(s & (1 << (a[x][y] - 1)))) {
      f[x][y] = s | (1 << (a[x][y] - 1));
      ans = (ans + dfs(x, y + 1)) % mo;
    }
    return ans;
  }
  for (int i = 1; i <= k; i++)
    if (!(s & (1 << (i - 1)))) {
      f[x][y] = s | (1 << (i - 1));
      bz[i]++;
      if (bz[i] == 1) {
        if (!bj) flow = dfs(x, y + 1), bj = true;
        ans = (ans + flow) % mo;
      } else
        ans = (ans + dfs(x, y + 1)) % mo;
      bz[i]--;
    }
  return ans;
}
int main() {
  cin >> n >> m >> k;
  if (n + m - 1 > k) {
    cout << "0";
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j], bz[a[i][j]]++;
  cout << dfs(1, 1);
  return 0;
}
