import java.util.*;
import java.io.*;
public class Main
{
static int r , c , t , up , down;
static int[][] map;
static Queue<int[]> q;
static int[] dx = {-1,1,0,0};
static int[] dy = {0,0,-1,1};
{
r =
integer.
parseInt(st.
nextToken());
c =
integer.
parseInt(st.
nextToken());
t =
integer.
parseInt(st.
nextToken());
map = new int[r][c];
for(int i = 0 ; i < r ; i++)
{
for(int j = 0 ; j < c ; j++)
{
int tmp =
integer.
parseInt(st.
nextToken());
if(tmp == -1) down = i;
map[i][j] = tmp;
}
}
up = down-1;
while(t > 0)
{
q = new LinkedList<>();
for(int i = 0 ; i < r ; i++)
{
for(int j = 0 ; j < c ; j++)
{
if(map[i][j] > 0)
q.add(new int[]{i,j});
}
}
spread();
push();
t--;
}
int ans = 0;
for(int i = 0 ; i < r ; i++)
{
for(int j = 0 ; j < c ; j++)
{
if(map[i][j] > -1) ans += map[i][j];
}
}
}
public static void spread()
{
while(!q.isEmpty())
{
int[] arr = q.poll();
int x = arr[0];
int y = arr[1];
if(map[x][y] < 5) continue;
int amount = (map[x][y]/5);
for(int i = 0 ; i < 4 ; i++)
{
int nx = x + dx[i];
int ny = y + dy[i];
if(nx >=0 && nx < r && ny >= 0 && ny < c)
{
if(map[nx][ny] != -1)
{
map[nx][ny] += amount;
map[x][y] -= amount;
}
}
}
}
}
public static void push()
{
for(int i = up-1 ; i > 0 ; i--)
{
map[i][0] = map[i-1][0];
}
for(int i = 0 ; i < c-1 ; i++)
{
map[0][i] = map[0][i+1];
}
for(int i = 0 ; i < up ; i++)
{
map[i][c-1] = map[i+1][c-1];
}
for(int i = c-1 ; i > 1 ; i--)
{
map[up][i] = map[up][i-1];
}
map[up][1] = 0;
for(int i = down+1 ; i < r-1 ; i++)
{
map[i][0] = map[i+1][0];
}
for(int i = 0 ; i < c-1 ; i++)
{
map[r-1][i] = map[r-1][i+1];
}
for(int i = r-1 ; i > down ; i--)
{
map[i][c-1] = map[i-1][c-1];
}
for(int i = c-1 ; i > 1 ; i--)
{
map[down][i] = map[down][i-1];
}
map[down][1] = 0;
}
}