#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
const int INF = 20 * 1e6 + 1;
int n, m, k;
int dfs(pair<int, int> u, int rem, vec<vec<int>> &hor, vec<vec<int>> &ver, vec<vec<int>> *dp) {
	if(rem == 0) {
		return 0;
	}
	rem--;
	if(dp[rem][u.fst][u.scd] != -1) {
		return dp[rem][u.fst][u.scd];
	}
	dp[rem][u.fst][u.scd] = INF;
	
	int x, y;
	y = u.scd;
	
	x = u.fst-1;
	if(x >= 0) {
		dp[rem][u.fst][u.scd] = min(dp[rem][u.fst][u.scd], ver[x][y] + dfs({x, y}, rem, hor, ver, dp));
	}
	
	x = u.fst + 1;
	if(x < n) {
		dp[rem][u.fst][u.scd] = min(dp[rem][u.fst][u.scd], ver[x - 1][y] + dfs({x, y}, rem, hor, ver, dp));
	}
	
	x = u.fst;
	
	y = u.scd-1;
	if(y >= 0) {
		dp[rem][u.fst][u.scd] = min(dp[rem][u.fst][u.scd], hor[x][y] + dfs({x, y}, rem, hor, ver, dp));
	}
	
	y = u.scd + 1;
	if(y < m) {
		dp[rem][u.fst][u.scd] = min(dp[rem][u.fst][u.scd], hor[x][y - 1] + dfs({x, y}, rem, hor, ver, dp));
	}
	
	return dp[rem][u.fst][u.scd];
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> m >> k;
	if(k & 1) {
		int i, j;
		for(i = 0; i < n; i++) {
			for(j = 0; j < m; j++) {
				cout << "-1 ";
			}
			cout << "\n";
		}
		return 0;
	}
	k >>= 1;
	vec<vec<int>> hor(n, vec<int>(m - 1)), ver(n - 1, vec<int>(m)), dp[k];
	int i, j;
	for(i = 0; i < k; i++) {
		dp[i] = vec<vec<int>>(n, vec<int>(m, -1));
	}
	m--;
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			cin >> hor[i][j];
		}
	}
	m++;
	n--;
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			cin >> ver[i][j];
		}
	}
	n++;
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			cout << (dfs({i, j}, k, hor, ver, dp) << 1) << " ";
		}
		cout << "\n";
	}
}
