#include <bits/stdc++.h>   using namespace std;   inline int min(int _a, int _b) { return _a < _b ? _a : _b; }   inline int max(int _a, int _b) { return _a > _b ? _a : _b; }   template <class _T>   inline void rd(_T &_a) {     int _f = 0, _ch = getchar();     _a = 0;     while (_ch <  0  || _ch >  9 ) {       if (_ch ==  - ) _f = 1;       _ch = getchar();     }     while (_ch >=  0  && _ch <=  9 ) _a = _a * 10 + _ch -  0 , _ch = getchar();     if (_f) _a = -_a;   }   const int inf = 0x3f3f3f3f;   const double eps = 1e-8;   const int mod = 1e9 + 7, N = 15;   int mp[N][N], f[N][N], ct[N], n, m, k, ans;   void dfs(int x, int y) {     if (y > m) x++, y = 1;     if (x > n) {       ans++;       ans %= mod;       return;     }     int st = f[x - 1][y] | f[x][y - 1], pre, d = -1;     if (n + m - x - y + 1 > k - __builtin_popcount(st)) return;     for (int i = 1; i <= k; i++)       if (!(st >> i - 1 & 1) && (!mp[x][y] || mp[x][y] == i)) {         f[x][y] = st | (1 << i - 1);         ct[i]++;         if (ct[i] == 1) {           if (~d)             ans += d;           else {             pre = ans;             dfs(x, y + 1);             d = ans - pre;           }         } else           dfs(x, y + 1);         ans %= mod;         ct[i]--;       }   }   int main() {     rd(n);     rd(m);     rd(k);     if (n + m - 1 > k) return puts( 0 ), 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         rd(mp[i][j]);         if (mp[i][j]) ct[mp[i][j]]++;       }     dfs(1, 1);     printf( %d , ans);     return 0;   }   