#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int Days[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int read() {
  int ans = 0;
  bool f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = getchar();
  return f ? ans : -ans;
}
int n, m, k;
int graph[25][25];
int vis[25][25][25];
int hascol[25];
long long ans;
long long calc(int x, int y) {
  long long res = 1;
  for (int i = x; i > x - y; i--) res *= i;
  res %= 1000000007;
  return res % 1000000007;
}
void DFS(int x = 0, int y = 0, int maxcol = 0) {
  if (x == n) {
    for (int i = 1; i <= maxcol; i++)
      for (int j = i + 1; j <= maxcol; j++)
        if (hascol[i] && hascol[j] && hascol[i] == hascol[j]) return;
    int hascolcnt = 0;
    for (int i = 1; i <= maxcol; i++)
      if (hascol[i]) hascolcnt++;
    ans += calc(k - hascolcnt, maxcol - hascolcnt);
    ans %= 1000000007;
    return;
  }
  if (y == m) {
    DFS(x + 1, 0, maxcol);
    return;
  }
  for (int col = 1; col <= min(maxcol + 1, k); col++) {
    if (vis[x][y][col]) continue;
    for (int i = x; i < n; i++)
      for (int j = y; j < m; j++) vis[i][j][col]++;
    bool ok = 1;
    if (graph[x][y])
      if (hascol[col] && hascol[col] != graph[x][y]) ok = 0;
    if (ok) {
      bool filled = 0;
      if (!hascol[col]) hascol[col] = graph[x][y], filled = 1;
      DFS(x, y + 1, max(maxcol, col));
      if (filled) hascol[col] = 0;
    }
    for (int i = x; i < n; i++)
      for (int j = y; j < m; j++) vis[i][j][col]--;
  }
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  if (n + m - 1 > k) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> graph[i][j];
  DFS();
  cout << ans % 1000000007;
  return 0;
}
