#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long LL;
const int N = 55;
const int MOD = 1e9 + 7;
LL memo[N][N][14][13];
int n, m, k, w[N][N];
int dx[2] = {1, 0};
int dy[2] = {0, 1};
bool valid(int x, int y)
{
return x >= 1 && x <= n && y >= 1 && y <= m;
}
LL dfs(int x, int y, int maxValue, int treasure)
{
if (x == n && y == m)
{
//由于当前站在(x, y)上,正在选择(x, y)上的物品拿不难,所以有两种满足条件的状态
if (treasure == k || (treasure == k-1 && w[n][m] > maxValue)) return 1;
return 0;
}
if (memo[x][y][maxValue][treasure] != -1) return memo[x][y][maxValue][treasure];
LL res = 0;
for (int i = 0; i < 2; ++i)
{
int nx = x + dx[i], ny = y + dy[i];
if (valid(nx, ny))
{
if (w[x][y] > maxValue && treasure+1 <= k)
{
//可以拿
res = (res + dfs(nx, ny, w[x][y], treasure+1)) % MOD;
}
//不拿(满足可以拿的条件也可以选择不拿)
res = (res + dfs(nx, ny, maxValue, treasure)) % MOD;
}
}
return memo[x][y][maxValue][treasure] = res;
}
int main()
{
//memo初始化为-1, -1代表该状态为走过, 若该状态为0, 则代表该状态没有满足情况的方案
memset(memo, -1, sizeof(memo));
scanf("%d %d %d", &n, &m, &k);
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
scanf("%d", &w[i][j]);
w[i][j]++;
}
}
printf("%lld", dfs(1, 1, 0, 0));
return 0;
}