#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int t[11][11];
int ban[11][11][11];
int match[11];
int ans = 0;
void dfs(int x, int y, int lim) {
  if (x == n) {
    for (int i = 1; i < lim + 1; i++)
      for (int j = i + 1; j < lim + 1; j++) {
        if (match[i] * match[j] != 0)
          if (match[i] == match[j]) return;
      }
    int have = 0, havent = k;
    for (int i = 1; i < lim + 1; i++)
      if (match[i])
        havent--;
      else
        have++;
    int cur = 1;
    for (int i = 0; i < have; i++) {
      cur *= havent;
      cur %= ((int)1e9 + 7);
      havent--;
    }
    ans += cur;
    ans %= ((int)1e9 + 7);
    return;
  }
  for (int i = 1; i <= min(lim + 1, k); i++) {
    if (ban[x][y][i]) continue;
    if (t[x][y] != 0) {
      if (match[i] != 0 && match[i] != t[x][y]) continue;
    }
    bool ret = 0;
    if (match[i] == 0) match[i] = t[x][y], ret = 1;
    ;
    for (int xx = x; xx < n; xx++)
      for (int yy = y; yy < m; yy++) ban[xx][yy][i]++;
    int nx = x, ny = y;
    ny++;
    nx += ny / m;
    ny %= m;
    dfs(nx, ny, max(i, lim));
    if (ret) match[i] = 0;
    for (int xx = x; xx < n; xx++)
      for (int yy = y; yy < m; yy++) ban[xx][yy][i]--;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  if (n + m - 1 > k) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> t[i][j];
  dfs(0, 0, 0);
  cout << ans << endl;
  return 0;
}
