
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define int ll
#define vi vector<int>
#define pii pair<ll,ll>
#define piii pair<int, pii>
#define pb push_back
#define fs first
#define sc second
//#define ONLINE_JUDGE
#define endl "\n"
#define pow2(i) (1<<(i))  
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define precise(x) cout<<fixed<<setprecision(x)
#define all(v) (v).begin(),(v).end()
const ll mod = 1e9+7;
//const ll mod = 998244353;




int n,m,k; int r[502][502],d[502][502]; int dp[502][502][11];
void solve()
{
	cin>>n>>m>>k;

	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=m+1;j++)
			d[i][j]=r[i][j]=mod;
	for(int i=1;i<=n;i++)
		for(int j=1;j<m;j++)
			cin>>r[i][j];
	for(int i=1;i<n;i++)
		for(int j=1;j<=m;j++)
			cin>>d[i][j];

	if(k&1)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
				cout<<-1<<" ";
			cout<<endl;
		}
		return;
	}
	k/=2;

	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=m+1;j++)
			for(int k1=0;k1<=k;k1++)
				dp[i][j][k1]=mod;

	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			dp[i][j][0]=0;

	for(int k1=1;k1<=k;k1++)
	{
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
			{
				dp[i][j][k1] = min(min(r[i][j]+dp[i][j+1][k1-1],r[i][j-1]+dp[i][j-1][k1-1]), min(d[i][j]+dp[i+1][j][k1-1],d[i-1][j]+dp[i-1][j][k1-1]));
			}
		//if(k1==2)d3(dp[2][2][2],d[1][2],dp[1][2][1]);
		//d2("*******",k1);
		/*for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
				cout<<dp[i][j][k1]<<" ";
			cout<<endl;
		}*/
	}

		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
				cout<<dp[i][j][k]*2<<" ";
			cout<<endl;
		}
}
 
signed main()
{
    #ifndef ONLINE_JUDGE
 	freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
 
    fifo
    int tt=1;
 
    //cin>>tt;
 	//d1(tt);
 	//d1(f00());
    for(ll tc=1;tc<=tt;++tc)
    {
    	//cout<<"Case #"<<tc<<": ";
        solve();
    }
}