func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 5;   int n, m, k, a[N][N];   const int mod = 1e9 + 7;   int f[N][N], used[15];   int ans = 0;   inline void Plus(int &x, const int &y) {     x += y;     if (x >= mod) x -= mod;   }   inline int dfs(int x, int y) {     if (y > m) y = 1, ++x;     if (x == n + 1) return 1;     int now = f[x][y - 1] | f[x - 1][y], tmp = -1, res = 0;     int num = 0;     for (int i = k; i >= 1; i--) num += !((now >> (i - 1)) & 1);     if (n + m - x - y + 1 > num) return 0;     for (int i = 1; i <= k; i++)       if (!(now >> (i - 1) & 1)) {         if (!a[x][y] || a[x][y] == i) {           f[x][y] = now | (1 << i - 1);           if (++used[i] == 1) {             if (tmp == -1) tmp = dfs(x, y + 1);             Plus(res, tmp);           } else             Plus(res, dfs(x, y + 1));           --used[i];         }       }     return res;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]), ++used[a[i][j]];     if (n + m - 1 > k) return printf( 0 n ), 0;     printf( %d n , dfs(1, 1));   }   