#include <bits/stdc++.h>
using namespace std;
#define qc ios::sync_with_stdio(0)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef pair<ll, ll> Pair;
int n, m, k;
int x[501][501];
int y[501][501];
ll dis[501][501][11];

void work(int i, int j, int t) {
	if (i < n)
		dis[i][j][t] = min(dis[i][j][t], dis[i + 1][j][t - 1] + x[i][j]);
	if (i > 1)
		dis[i][j][t] = min(dis[i][j][t], dis[i - 1][j][t - 1] + x[i - 1][j]);
	if (j < m)
		dis[i][j][t] = min(dis[i][j][t], dis[i][j + 1][t - 1] + y[i][j]);
	if (j > 1)
		dis[i][j][t] = min(dis[i][j][t], dis[i][j - 1][t - 1] + y[i][j - 1]);
}

int main() {
	qc, cin.tie(0);
	memset(dis, 0x3f, sizeof(dis));
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			dis[i][j][0] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j < m; j++)
			cin >> y[i][j];
	for (int i = 1; i <= n - 1; i++)
		for (int j = 1; j <= m; j++)
			cin >> x[i][j];
	if (k % 2 != 0) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++)
				cout << "-1 ";
			cout << "\n";
		}
		return 0;
	}
	for (ll t = 1; t <= k / 2; t++) {
		for (ll i = 1; i <= n; i++)
			for (ll j = 1; j <= m; j++) {
				work(i, j, t);
			}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cout << dis[i][j][k / 2] * 2 << " ";
		}
		cout << "\n";
	}
	return 0;
}
