#include <bits/stdc++.h>
using namespace std;
const int N = 35, M = 15, MOD = 1000000007;
int n, m, k, ans, a[N][N];
bool used[N][N][M], vis[M];
int dfs(int x, int y) {
  if (x == n + 1) return 1;
  int s = 0;
  for (int i = 1; i <= k; i++) {
    used[x][y][i] = used[x - 1][y][i] | used[x][y - 1][i];
    if (!used[x][y][i]) s++;
  }
  if (s < n - x + m - y + 1) return 0;
  int cnt = 0, ans = 0, cpy = -1;
  for (int i = 1; i <= k; i++) {
    if (a[x][y] && a[x][y] != i) continue;
    if (!used[x][y][i]) {
      used[x][y][i] = 1;
      if (!vis[i]) {
        if (cpy < 0) {
          vis[i] = 1;
          if (y < m)
            cpy = dfs(x, y + 1);
          else
            cpy = dfs(x + 1, 1);
          vis[i] = 0;
        }
        ans = (ans + cpy) % MOD;
      } else if (y < m)
        ans = (ans + dfs(x, y + 1)) % MOD;
      else
        ans = (ans + dfs(x + 1, 1)) % MOD;
      used[x][y][i] = 0;
    }
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n + m - 1 > k) return !printf("0");
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      vis[a[i][j]] = 1;
    }
  printf("%d\n", dfs(1, 1));
  return 0;
}
