#include <bits/stdc++.h>
using namespace std;
const int NS = 1111;
const int MOD = 1000000007;
int n, m, k;
int v[11], u[NS];
int s[NS][NS], a[NS][NS];
long long dfs(int x, int y) {
  if (y > m) return dfs(x + 1, 1);
  if (x > n) return 1;
  int cur = s[x - 1][y] | s[x][y - 1];
  if (n + m - x - y + __builtin_popcount(cur) >= k) return 0;
  long long ans = 0, w = -1;
  for (int t = (~cur) & ((1 << k) - 1); t; t -= t & -t) {
    int i = u[t & -t] + 1;
    if (!(cur & (1 << (i - 1))) && (a[x][y] == i || !a[x][y])) {
      s[x][y] = cur | (1 << (i - 1));
      if (v[i]++)
        ans += dfs(x, y + 1);
      else {
        if (w == -1) w = dfs(x, y + 1);
        ans += w;
      }
      v[i]--;
      ans %= MOD;
    }
  }
  return ans;
}
int main() {
  int i, j;
  while (~scanf("%d%d%d", &n, &m, &k)) {
    memset(v, 0, sizeof(v));
    for (i = 0; i < k; ++i) u[1 << i] = i;
    for (i = 1; i <= n; ++i) {
      for (j = 1; j <= m; ++j) {
        scanf("%d", &a[i][j]);
        v[a[i][j]]++;
      }
    }
    long long ans = dfs(1, 1);
    cout << ans << endl;
  }
  return 0;
}
