#include using namespace std; const int N = 55; const int MOD = 1e9 + 7; int dp[N][N][13][14]; int g[N][N]; int n, m, k; int main() { cin >> n >> m >> k; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> g[i][j]; g[i][j]++; } } dp[1][1][1][g[1][1]] = 1; dp[1][1][0][0] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { for (int u = 0; u <= k; u++) { for (int v = 0; v <= 13; v++) { dp[i][j][u][v] = (dp[i][j][u][v] + dp[i - 1][j][u][v]) % MOD; dp[i][j][u][v] = (dp[i][j][u][v] + dp[i][j - 1][u][v]) % MOD; if (u > 0 && v == g[i][j]) { for (int c = 0; c < v; c++) { dp[i][j][u][v] = (dp[i][j][u][v] + dp[i - 1][j][u][c]) % MOD; dp[i][j][u][v] = (dp[i][j][u][v] + dp[i][j - 1][u - 1][c]) % MOD; } } } } } } int res = 0; for (int i = 0; i <= 13; i++) res = (res + dp[n][m][k][i]) % MOD; cout << res << endl; return 0; }