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

int n, m, k;
int vEdge[504][504];
int hEdge[504][504];
int dp[504][504][24];

int cal(int i, int j, int rem) {
	if (rem == 0) {
		return 0;
	}
	int& ret = dp[i][j][rem];
	if (ret != -1)	return ret;
	ret = INT_MAX;
	if (0 < i) {
		ret = min(ret, cal(i-1, j, rem-2) + 2*vEdge[i-1][j]);
	}
	if (0 < j) {
		ret = min(ret, cal(i, j-1, rem-2) + 2*hEdge[i][j-1]);
	}
	if (i < n-1) {
		ret = min(ret, cal(i+1, j, rem-2) + 2*vEdge[i][j]);
	}
	if (j < m-1) {
		ret = min(ret, cal(i, j+1, rem-2) + 2*hEdge[i][j]);
	}
	return ret;
}

int main() {
	cin>>n>>m>>k;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++) {
		for(int j = 0; j < m-1; j++)
			cin>>hEdge[i][j];
	}
	for (int i = 0; i < n-1; i++) {
		for(int j = 0; j < m; j++)
			cin>>vEdge[i][j];
	}
	for (int i = 0; i < n; i++){
		for(int j = 0; j < m; j++)
			k%2 ? cout<<-1<<' ' : cout<<cal(i, j, k)<<' ';
		cout<<'\n';
	}
	return 0;
}