#include <bits/stdc++.h>
#define ll long long int
#define s second 
#define f first 
#define pb push_back 
#define mk make_pair
#define forn(i,n) for(ll i=0;i<n;i++) 
using namespace std ;
ll dp[505][505][25] ;

int n,m,k ;
int hor[505][505] ;
int ver[505][505] ;
ll go(int i,int j,int left)
{
	if(left == 0)
		return 0 ;

	if(dp[i][j][left] != -1)
        return dp[i][j][left] ;
	ll temp = LLONG_MAX ;
	ll a ;
	if(i>0)
		a = ver[i-1][j] + go(i-1,j,left-1) ;
	else
		a = INT_MAX ;
	ll b ;
	if(i<n-1)
		b = ver[i][j] + go(i+1,j,left-1) ;
	else 
		b = INT_MAX ;
    
    temp = temp ;
	temp = min(temp,min(a,b)) ;
	ll c ;
	if(j>0)
		c = hor[i][j-1] + go(i,j-1,left-1) ;
	else
		c = INT_MAX ;
	ll d ;
	if(j<m-1)
		d = hor[i][j] + go(i,j+1,left-1) ;
	else
		d = INT_MAX ;

	temp = min(temp,min(c,d)) ;

	return dp[i][j][left] = temp ;  

}
int main()
{

	cin>>n>>m>>k ;
    
	memset(dp,-1,sizeof(dp)) ;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m-1;j++)
		{
			cin>>hor[i][j] ;
		}
	}

	for(int i=0;i<n-1;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>ver[i][j] ;
		}
	}

	if(k & 1)
	{
		forn(i,n)
		{
			forn(j,m)
				{
					cout<<"-1 " ;
				}
				cout<<"\n" ;
		}

		return 0 ;
	}

	forn(i,n)
	{
		forn(j,m)
		{
			ll ans = go(i,j,k/2) ;
			cout<<2*ans<<" " ;
		}
		cout<<"\n" ;
	}
	 

}