#include <bits/stdc++.h>
using namespace std;
// Prioridade
typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (int)(b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007ll
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)
#define W(x) cerr << "\033[31m"<<  #x << " = " << x << "\033[0m" << endl;
// fim da Prioridade
vpi g[250600];
int dp[250600][12];
int solve(int i, int k){
	if(k == 0) return 0;
	if(dp[i][k] != -1) return dp[i][k];
	int ans = INF;
	for(auto [u, d] : g[i]){
		ans = min(ans, solve(u, k-1) + d);
	}
	return dp[i][k] = ans;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++){
		for(int j = 0; j < m-1; j++){
			int val;
			cin >> val;
			g[i*500 + j].PB({i*500 + j + 1, val});
			g[i*500 + j + 1].PB({i*500 + j, val});
	
		}
	}
	for (int i = 0; i < n-1; i++){
		for(int j = 0; j < m; j++){
			int val;
			cin >> val;
			g[i*500 + j].PB({(i+1)*500 + j, val});
			g[(i+1)*500 + j].PB({i*500 + j, val});
		}
	}
	if(k & 1){
		for(int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				cout << -1 << " ";
			}
			cout << endl;
		}
		return 0;
	}
	memset(dp,-1,sizeof dp);
	for(int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cout << solve(i*500 + j,k/2)*2 << " ";
		}
		cout << endl;
	}
	
	
	return 0;
}
 
