#include <bits/stdc++.h>
using namespace std;
const int BufferSize = 1 << 16;
char buffer[BufferSize], *Head, *Tail;
inline char Getchar() {
  if (Head == Tail) {
    int l = fread(buffer, 1, BufferSize, stdin);
    Tail = (Head = buffer) + l;
  }
  return *Head++;
}
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m, k, A[15][15];
int s[15][15], ans, col[15][15], use[15];
int dfs(int x, int y) {
  if (x > n) return 1;
  s[x][y] = s[x - 1][y] | s[x][y - 1];
  int cnt = 0;
  for (int i = 0; i < k; i++)
    if (s[x][y] >> i & 1) cnt++;
  if (k - cnt < (n - x) + (m - y) + 1) return 0;
  if (A[x][y] && (s[x][y] >> A[x][y] - 1 & 1)) return 0;
  int ans = 0, sum = -1;
  if (!A[x][y]) {
    for (int i = 1; i <= k; i++)
      if (!(s[x][y] >> i - 1 & 1)) {
        if (!use[i] && sum >= 0) {
          ans += sum;
          if (ans >= 1000000007) ans -= 1000000007;
          continue;
        }
        s[x][y] ^= (1 << i - 1);
        use[i]++;
        col[x][y] = i;
        int tmp = 0;
        if (y < m)
          tmp = dfs(x, y + 1);
        else
          tmp = dfs(x + 1, 1);
        s[x][y] ^= (1 << i - 1);
        use[i]--;
        col[x][y] = 0;
        ans += tmp;
        if (ans >= 1000000007) ans -= 1000000007;
        if (!use[i]) sum = tmp;
      }
  } else {
    s[x][y] ^= (1 << A[x][y] - 1);
    use[A[x][y]]++;
    col[x][y] = A[x][y];
    if (y < m)
      ans += dfs(x, y + 1);
    else
      ans += dfs(x + 1, 1);
    s[x][y] ^= (1 << A[x][y] - 1);
    use[A[x][y]]--;
    col[x][y] = 0;
    if (ans >= 1000000007) ans -= 1000000007;
  }
  return ans;
}
int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) A[i][j] = read(), use[A[i][j]] = 1;
  printf("%d\n", dfs(1, 1));
  return 0;
}
