#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T, typename U>
U type_cast(const T& a) {
  U res;
  stringstream ss;
  ss << a;
  ss >> res;
  return res;
}
template <typename T>
using min_queue = priority_queue<T, vector<T>, greater<T> >;
template <typename T>
using max_queue = priority_queue<T>;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
int n, m, k, ans, a[15][15];
int used[15][15][15], mp[15];
void dfs(int x, int y, int mc) {
  if (x == n) {
    for (int c = (1); c <= (mc); ++c)
      for (int qc = (c + 1); qc <= (mc); ++qc)
        if (mp[c] && mp[qc] && mp[c] == mp[qc]) return;
    int a = 0, b = k;
    for (int c = (1); c <= (mc); ++c) {
      if (mp[c])
        b--;
      else
        a++;
    }
    int curans = 1;
    for (; a--; b--) curans = curans * b % mod;
    ans += curans;
    ans %= mod;
    return;
  }
  for (int c = (1); c <= (min(mc + 1, k)); ++c) {
    if (used[x][y][c]) continue;
    for (int i = (x); i <= (n - 1); ++i)
      for (int j = (y); j <= (m - 1); ++j) used[i][j][c]++;
    if (!(a[x][y] && mp[c] && mp[c] != a[x][y])) {
      bool flag = false;
      if (mp[c] == 0) {
        mp[c] = a[x][y];
        flag = true;
      }
      if (y < m - 1)
        dfs(x, y + 1, max(mc, c));
      else
        dfs(x + 1, 0, max(mc, c));
      if (flag) mp[c] = 0;
    }
    for (int i = (x); i <= (n - 1); ++i)
      for (int j = (y); j <= (m - 1); ++j) used[i][j][c]--;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  if (n + m > k + 1) {
    cout << "0\n";
    return 0;
  }
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (m - 1); ++j) cin >> a[i][j];
  dfs(0, 0, 0);
  cout << ans << endl;
  return 0;
}
