#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[15][15], v[1 << 15], vis[15], vt[15][15];
inline int dfs(int x, int y) {
  if (n + m > k + 1) return 0;
  if (y == m + 1) {
    x++;
    y = 1;
  }
  if (x == n + 1) {
    return 1;
  }
  int wys = vt[x - 1][y] | vt[x][y - 1];
  int bj = 2147483647;
  int ans = 0;
  for (int i = (~wys) & ((1 << k) - 1); i > 0; i -= (i & (-i))) {
    int t = v[i & (-i)] + 1;
    if (!a[x][y] || a[x][y] == t) {
      vt[x][y] = wys | (1 << (t - 1));
      vis[t]++;
      if (vis[t] == 1) {
        if (bj == 2147483647) bj = dfs(x, y + 1);
        ans += bj;
      } else if (vis[t])
        ans += dfs(x, y + 1);
      ans %= 1000000007;
      vis[t]--;
    }
  }
  return ans;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      vis[a[i][j]]++;
    }
  }
  for (int i = 1; i <= k; i++) v[1 << i] = i;
  int ans1 = dfs(1, 1);
  cout << ans1;
  return 0;
}
