#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
int inline in() {
  int x = 0, c;
  for (; (unsigned)((c = getchar()) - '0') >= 10;) {
    if (c == '-') return -in();
    if (!~c) throw ~0;
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while ((unsigned)((c = getchar()) - '0') < 10);
  return x;
}
int n, m, k;
int ans;
const int mod = 1e9 + 7;
const int Maxn = 20;
int grid[Maxn][Maxn], res[Maxn][Maxn], mask[Maxn][Maxn];
int mp[Maxn];
void check(int used) {
  memset(mp, 0, sizeof(mp));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (grid[i][j] != 0) {
        int now = res[i][j];
        if (mp[now] != 0 && mp[now] != grid[i][j]) return;
        mp[now] = grid[i][j];
      }
  for (int i = 1; i <= k; i++)
    for (int j = i + 1; j <= k; j++) {
      if (mp[i] != 0 && mp[i] == mp[j]) return;
    }
  int tmp = 1;
  int free = 0, cols = k;
  for (int i = 1; i <= used; i++) {
    if (mp[i] == 0)
      free++;
    else
      cols--;
  }
  for (int i = 0; i < free; i++) {
    tmp = (long long)tmp * (cols - i) % mod;
  }
  ans = ((long long)ans + tmp) % mod;
}
void go(int row, int col, int used) {
  if (row == n + 1) {
    check(used);
    return;
  }
  mask[row][col] = (mask[row - 1][col] | mask[row][col - 1]);
  for (int c = 1; c <= k && c <= used + 1; c++) {
    if ((mask[row][col]) >> c & 1) continue;
    mask[row][col] ^= (1 << c);
    res[row][col] = c;
    if (col == m) {
      go(row + 1, 1, max(c, used));
    } else {
      go(row, col + 1, max(c, used));
    }
    mask[row][col] ^= (1 << c);
    res[row][col] = 0;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &grid[i][j]);
    }
  }
  if (n + m - 1 > k) {
    printf("%d\n", 0);
    return 0;
  }
  go(1, 1, 0);
  printf("%d\n", ans);
  return 0;
}
