#include<bits/stdc++.h>
#define ll long long int
#define eb emplace_back
#define pb push_back
#define MOD 10000000000007  // 1e9+7
#define LOOP(i, a, b) for(int i=a; i<b; i++)
#define IN(a) scanf("%lld", &a)
#define OUT(a) printf("%lld", a)
#define NL printf("\n")
#define endl "\n"
#define MAX 300000    // Default: 1e5 + 10
#define DB_ON 0
#define DB if(DB_ON)
using namespace std;

/*
	|     0
   - -   1 3
    |     2
*/

ll n, m, k, tp;
ll grid[MAX][4];
ll out[520][520];
ll dp[MAX][20];

ll goBaby(int i, int j, ll stepRemaining){
	if(stepRemaining == 0){
		return 0;
	}
	if(dp[i*510 + j][stepRemaining])	return dp[i*510+j][stepRemaining];
	if(i<0 || i>n-1 || j<0 || j>m-1)	return 0;

	ll mn = MOD;
	if(i+1<n){
		mn = min( 2 * grid[i*510 + j][2] + goBaby(i+1, j, stepRemaining - 2), mn );
	}
	if(i-1 >= 0){
		mn = min( 2 * grid[i*510 + j][0] + goBaby(i-1, j, stepRemaining-2), mn );
	}
	if(j+1 < m){
		mn = min( 2*grid[i*510 + j][3] + goBaby(i, j+1, stepRemaining - 2), mn );
	}
	if(j-1 >= 0){
		mn = min( 2*grid[i*510+j][1] + goBaby(i, j-1, stepRemaining-2), mn);
	}

	return dp[i*510+j][stepRemaining] = mn;
}

int main()
{
	IN(n); IN(m); IN(k);
	LOOP(i, 0, n){
		grid[i*510 + 0][1] = MOD;
		grid[i*510 + m-1][3] = MOD;
		LOOP(j, 0, m-1){
			IN(tp);
			grid[i*510 + j][3] = tp;
			grid[i*510 + j+1][1] = tp;
		}
	}

	LOOP(i, 0, n-1){
		LOOP(j, 0, m){
			IN(tp);
			grid[i*510 + j][2] = tp;
			grid[(i+1)*510 + j][0] = tp;
		}
	}

	LOOP(j, 0, m){
		grid[0 + j][0] = MOD;
		grid[(n-1)*510 + j][2] = MOD;
	}

	if(k%2==1){
		LOOP(i, 0, n){
			LOOP(j, 0, m){
				printf("-1 ");
			}
			NL;
		}
	}
	else{
		LOOP(i, 0, n){
			LOOP(j, 0, m){
				printf("%lld ", goBaby(i, j, k));
			}
			NL;
		}
	}

	return 0;
}