/* https://codeforces.com/contest/1517/submission/114002376 (Dukkha) */
#include <stdio.h>
#include <string.h>

#define N	500
#define M	500
#define K	10
#define INF	0x3f3f3f3f

int min(int a, int b) { return a < b ? a : b; }

int main() {
	static int aa[N][M - 1], bb[N - 1][M], dp[N][M], dq[N][M];
	int n, m, k, i, j;

	scanf("%d%d%d", &n, &m, &k);
	if (k % 2 != 0) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < m; j++)
				printf("-1 ");
			printf("\n");
		}
		return 0;
	}
	k /= 2;
	for (i = 0; i < n; i++)
		for (j = 0; j < m - 1; j++)
			scanf("%d", &aa[i][j]);
	for (i = 0; i < n - 1; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &bb[i][j]);
	while (k--) {
		for (i = 0; i < n; i++)
			for (j = 0; j < m; j++) {
				dq[i][j] = INF;
				if (i > 0)
					dq[i][j] = min(dq[i][j], dp[i - 1][j] + bb[i - 1][j]);
				if (i + 1 < n)
					dq[i][j] = min(dq[i][j], dp[i + 1][j] + bb[i][j]);
				if (j > 0)
					dq[i][j] = min(dq[i][j], dp[i][j - 1] + aa[i][j - 1]);
				if (j + 1 < m)
					dq[i][j] = min(dq[i][j], dp[i][j + 1] + aa[i][j]);
			}
		for (i = 0; i < n; i++)
			memcpy(dp[i], dq[i], m * sizeof *dq[i]);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)
			printf("%d ", dp[i][j] * 2);
		printf("\n");
	}
	return 0;
}
