You have a rectangular n × m-cell board. Some cells are already painted some of k colors. You need to paint each uncolored cell one of the k colors so that any path from the upper left square to the lower right one doesn't contain any two cells of the same color. The path can go only along side-adjacent cells and can only go down or right.

Print the number of possible paintings modulo 1000000007 (109 + 7).

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 1000, 1 ≤ k ≤ 10). The next n lines contain m integers each — the board. The first of them contains m uppermost cells of the board from the left to the right and the second one contains m cells from the second uppermost row and so on. If a number in a line equals 0, then the corresponding cell isn't painted. Otherwise, this number represents the initial color of the board cell — an integer from 1 to k.

Consider all colors numbered from 1 to k in some manner.

Output

Print the number of possible paintings modulo 1000000007 (109 + 7).

Examples

Input

2 2 4
0 0
0 0


Output

48


Input

2 2 4
1 2
2 1


Output

0


Input

5 6 10
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0


Output

3628800


Input

2 6 10
1 2 3 4 5 6
0 0 0 0 0 0


Output

4096
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
template <typename T>
inline T Abs(T x) {
  return (x >= 0) ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline string toStr(T x) {
  stringstream st;
  st << x;
  string s;
  st >> s;
  return s;
}
template <typename T>
inline int bit(T mask, int b) {
  return (b >= 0 && (mask & (T(1) << b)) != 0) ? 1 : 0;
}
inline int nextInt() {
  int x;
  if (scanf("%d", &x) != 1) throw;
  return x;
}
inline long long nextInt64() {
  long long x;
  if (scanf("%I64d", &x) != 1) throw;
  return x;
}
inline double nextDouble() {
  double x;
  if (scanf("%lf", &x) != 1) throw;
  return x;
}
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 1100;
const int MOD = INF + 7;
int n, m, k, a[MAXN][MAXN], s[MAXN][MAXN], res[MAXN][MAXN];
int orcolor[MAXN], mycolor[MAXN];
int f[MAXN], c[MAXN][MAXN];
int C(int n, int k) {
  if (n == k || k == 0) return 1;
  int &ans = c[n][k];
  if (ans == -1) ans = (C(n - 1, k) + C(n - 1, k - 1)) % MOD;
  return ans;
}
int get(int x, int y, int c, int c1) {
  if (c > k) return 0;
  if (x == n) return (1LL * C(k - c1, c - c1) * f[c - c1]) % MOD;
  if (y == m) return get(x + 1, 0, c, c1);
  int mask = 0;
  if (x > 0) mask |= s[x - 1][y];
  if (y > 0) mask |= s[x][y - 1];
  int ans = 0;
  for (int i = 0; i < (int)(c + 1); i++) {
    if (bit(mask, i)) continue;
    int need = a[x][y];
    if (need == -1) {
      res[x][y] = i;
      s[x][y] = mask | (1 << i);
      ans = (ans + get(x, y + 1, max(c, i + 1), c1)) % MOD;
      continue;
    }
    if (mycolor[need] != -1 && mycolor[need] != i) continue;
    if (orcolor[i] != -1 && orcolor[i] != need) continue;
    if (mycolor[need] == -1) {
      mycolor[need] = i;
      orcolor[i] = need;
      res[x][y] = i;
      s[x][y] = mask | (1 << i);
      ans = (ans + get(x, y + 1, max(c, i + 1), c1 + 1)) % MOD;
      mycolor[need] = -1;
      orcolor[i] = -1;
    } else {
      res[x][y] = i;
      s[x][y] = mask | (1 << i);
      ans = (ans + get(x, y + 1, max(c, i + 1), c1)) % MOD;
    }
  }
  return ans;
}
int main() {
  n = nextInt();
  m = nextInt();
  k = nextInt();
  if (n + m - 1 > k) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(k + 1); i++)
    f[i] = (i == 0) ? 1 : (1LL * f[i - 1] * i) % MOD;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) a[i][j] = nextInt() - 1;
  memset(c, 255, sizeof c);
  memset(orcolor, 255, sizeof orcolor);
  memset(mycolor, 255, sizeof mycolor);
  cout << get(0, 0, 0, 0) << endl;
  return 0;
}
