/*
	* Handle - i_m_mohit 
	* Author - Mohit Thakur
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327;
#define forr(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define pb push_back
#define vi vector<ll>
#define vvi vector<vi>
#define vpi vector<pi>
#define pi pair<ll,ll>
#define F first
#define S second
#define mp make_pair

const int mod1 = 1e9+7;
const int mod2 = 998244353;
ll bpow(ll a,ll b,ll m) 
{
    ll res = 1;
    while (b > 0) 
    {
        if (b & 1) res = (res * a)%m;
        a = (a * a)%m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll n,ll m)
	{return bpow(n,m-2,m);}
//factorize in n*rt(n)
void factorize(long long n,vpi&v) 
{ 
    int count = 0; 
    while (!(n % 2)) { 
        n >>= 1;  
        count++; 
    } 
  
    if (count) 
        v.push_back(make_pair(2,count)); 
  
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            v.push_back(make_pair(i,count));
    } 
  
    if (n > 2) 
        v.push_back(make_pair(n,1));
}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int n,m,k;
ll ways[505][505][11] = {0};
int wh[505][505];
int wv[505][505];
ll whr(int i,int j)
{
	if(i<0||i>n-1||j<0||j>=m-1)
		return mod1;
	else
		return wh[i][j];
}
ll wvr(int i,int j)
{
	if(i<0||i>=n-1||j<0||j>=m)
		return mod1;
	else
		return wv[i][j];
}
ll count_ways(int i,int j,int k)
{
	if(i>n-1||i<0||j<0||j>m-1) return mod1;
	if(ways[i][j][k]!=0) return ways[i][j][k];
	if(k==0) return 0;
	ll a = 2*wvr(i,j)+count_ways(i+1,j,k-1);
	ll b = 2*wvr(i-1,j)+count_ways(i-1,j,k-1);
	ll mi = min(a,b);
	ll c = 2*whr(i,j)+count_ways(i,j+1,k-1);
	mi = min(mi,c);
	ll d = 2*whr(i,j-1)+count_ways(i,j-1,k-1);
	mi = min(mi,d);
	return ways[i][j][k] = mi;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE 
    freopen("in.in", "r", stdin); 
    freopen("out.out", "w", stdout);  
	#endif
	int TT=1;
	//cin >> TT;
	while(TT--)
	{
		cin >> n >> m >> k;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m-1;j++)
				{
					cin >> wh[i][j];
				}
		}
		for(int i=0;i<n-1;i++)
		{
			for(int j=0;j<m;j++)
			{
				cin >> wv[i][j];
			}
		}
		if(k%2)
		{
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					cout << -1 << " ";
				}
				cout << endl;
			}
		}
		else
		{
			k = k/2;
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					for(int K=0;K<=k;K++)
					{
						ways[i][j][K] = 0;
					}
				}
			}
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<m;j++)
				{
					cout << count_ways(i,j,k)<<" ";
				}
				cout << endl;
			}
		}
	}
	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
	return 0;
}