#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
void qread(int &x) {
  int neg = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = 10 * x + c - '0', c = getchar();
  x *= neg;
}
const int maxn = 12;
const int mod = 1e9 + 7;
int n, m, k, ans;
int a[maxn][maxn], a2c[maxn], c2a[maxn], bad[maxn][maxn][maxn];
void go(int x, int y, int mc) {
  if (x == n) {
    int cnt1 = 0, cnt2 = k;
    for (int(i) = 1; (i) <= mc; i++) {
      if (c2a[i] == 0)
        cnt1++;
      else
        cnt2--;
    }
    int cur = 1;
    for (int(i) = 0; (i) < cnt1; i++) cur = 1LL * cur * (cnt2 - i) % mod;
    ans = (ans + cur) % mod;
    return;
  }
  for (int(i) = 1; (i) <= min(k, mc + 1); i++) {
    if (bad[x][y][i]) continue;
    if (a[x][y]) {
      if (c2a[i] != 0 && c2a[i] != a[x][y]) continue;
      if (a2c[a[x][y]] != 0 && a2c[a[x][y]] != i) continue;
    }
    int olda = a2c[a[x][y]], oldc = c2a[i];
    if (a[x][y] != 0) c2a[i] = a[x][y], a2c[a[x][y]] = i;
    for (int j = x; j < n; j++)
      for (int k = y; k < m; k++) bad[j][k][i]++;
    if (y == m - 1)
      go(x + 1, 0, max(mc, i));
    else
      go(x, y + 1, max(mc, i));
    for (int j = x; j < n; j++)
      for (int k = y; k < m; k++) bad[j][k][i]--;
    if (a[x][y] != 0) c2a[i] = oldc, a2c[a[x][y]] = olda;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    puts("0");
    return 0;
  }
  for (int(i) = 0; (i) < n; i++)
    for (int(j) = 0; (j) < m; j++) scanf("%d", &a[i][j]);
  go(0, 0, 0);
  printf("%d\n", ans);
  return 0;
}
