#include <bits/stdc++.h>
using namespace std;
const int N = 25, mod = 1e9 + 7;
int a[N][N], used[N][N], cur, first, n, m, k;
long long ans;
int count(int x) {
  int ans = 0;
  for (; x; x -= x & -x) ans++;
  return ans;
}
void dfs(int x, int y) {
  if (x == n) {
    int p = count(cur & ~first), q = count(((1 << k) - 1) & ~first);
    long long curans = 1;
    while (p--) {
      curans = (curans * q) % mod;
      q--;
    }
    ans = (ans + curans) % mod;
    return;
  }
  int nx = x, ny = y + 1;
  if (ny == m) {
    nx++;
    ny = 0;
  }
  if (a[x][y]) {
    dfs(nx, ny);
    return;
  } else {
    bool flag = true;
    int can = (1 << k) - 1;
    can &= ~used[x][y];
    for (int i = 0; (1 << i) <= can; i++) {
      if (!((can >> i) & 1)) continue;
      bool preused[N][N], preusedcur;
      preusedcur = true;
      memset(preused, false, sizeof(preused));
      if (!((cur >> i) & 1)) {
        if (flag)
          flag = false;
        else
          continue;
        preusedcur = false;
      }
      cur |= 1 << i;
      for (int px = x; px < n; px++)
        for (int py = y; py < m; py++) {
          if ((used[px][py] >> i) & 1)
            preused[px][py] = true;
          else
            used[px][py] |= 1 << i;
        }
      dfs(nx, ny);
      if (!preusedcur) cur &= ~(1 << i);
      for (int px = x; px < n; px++)
        for (int py = y; py < m; py++) {
          if (!preused[px][py]) used[px][py] &= ~(1 << i);
        }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j]) {
        first |= 1 << a[i][j] - 1;
        if ((used[i][j] >> a[i][j] - 1) & 1) {
          printf("0\n");
          return 0;
        }
        for (int r = 0; r < n; r++)
          for (int c = 0; c < m; c++) {
            if (r <= i && c <= j || r >= i && c >= j)
              used[r][c] |= 1 << a[i][j] - 1;
          }
      }
    }
  cur = first;
  dfs(0, 0);
  printf("%d\n", ans);
  return 0;
}
