#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
int n, m, k;
int cnt, tot, ans;
int cur[11][11], no[11][11];
int a[11][11];
int f[11];
int mp[11];
int calc(int used) {
  for (int i = 1; i <= k; i++) {
    mp[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!a[i][j]) {
        continue;
      }
      if (mp[cur[i][j]] == -1) {
        mp[cur[i][j]] = a[i][j];
      } else if (mp[cur[i][j]] != a[i][j]) {
        return 0;
      }
    }
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= i - 1; j++) {
      if (mp[i] != -1 && mp[i] == mp[j]) {
        return 0;
      }
    }
  }
  int x = 0, y = 0;
  for (int i = 1; i <= k; i++) {
    if (mp[i] == -1) {
      x++;
      if (i <= used) {
        y++;
      }
    }
  }
  return (f[x] / f[x - y]) % 1000000007;
}
void dfs(int id, int used) {
  if (used > k) {
    return;
  }
  if (id == tot) {
    memset(mp, 0, sizeof(mp));
    ans = (ans + calc(used)) % 1000000007;
    return;
  }
  int x = id / m + 1, y = id % m + 1;
  no[x][y] =
      no[x - 1][y] | no[x][y - 1] | (1 << cur[x - 1][y]) | (1 << cur[x][y - 1]);
  int mask = no[x][y];
  for (int i = 1; i <= used + 1; i++) {
    if ((mask & (1 << i)) == 0) {
      cur[x][y] = i;
      dfs(id + 1, max(used, i));
    }
  }
}
int main(int argc, char** argv) {
  cin >> n >> m >> k;
  if (n + m - 1 > k) {
    cout << 0 << endl;
    return 0;
  }
  tot = n * m;
  f[0] = 1;
  for (int i = 1; i <= 10; i++) {
    f[i] = (f[i - 1] * i) % 1000000007;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
