from functools import lru_cache
@lru_cache(maxsize=None)
def dfs(x,y,z,w):
#z:拿了几个宝物
#ans:记录方案数
#w:记录最大价值的宝物
global ans
print(ans)
if x==n-1 and y==m-1:
if z==k:
ans=ans+1
"""if z==k-1 and w<c[x][y]:
ans=ans+1"""
return
for dx,dy in [(1,0),(0,1)]:
nx,ny=x+dx,y+dy
if 0<=nx<n and 0<=ny<m:
dfs(nx, ny, z, w)
#选择拿起宝物,现在在x,y这个格子里
if c[x][y]>w:
dfs(nx,ny,z+1,c[x][y])
n,m,k=map(int,input().split())
c = [list(map(int, input().split())) for i in range(n)]
ans=0
dfs(0,0,0,-1)
print(ans )
"""
2 2 2
1 2
2 1
"""