#include<bits/stdc++.h>
#define lld      long long
#define int      lld
#define mp       make_pair
#define pb       push_back
#define ff       first
#define ss       second
#define pll      pair<lld,lld>
#define pii      pair<int,int>
#define vll      vector<lld>
#define vii      vector<int>
#define umap     unordered_map
#define lb       lower_bound
#define ub       upper_bound
#define all(x)   x.begin(),x.end()
#define sort1(x) sort(x,greater<int>())
#define rep(i,a,b) for(i = a; i < b; i++)
#define fio      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

namespace forever {
    template<class type1,class type2>
        inline istream &operator>>(istream &in,pair<type1,type2> &p)
        {
            in>>p.ff>>p.ss;
            return in;
        }
    template<class type1,class type2>
        inline ostream &operator<<(ostream &o,pair<type1,type2> &p)
        {
             o<<"("<<p.ff<<","<<p.ss<<")";
            return o;
        } 
    template<class type>
        inline ostream &operator<<(ostream &o,vector<type> &v)
        {
            for(int i=0;i<v.size();i++)
                o<<v[i]<<" ";
            return o;    
        }
    template<class t>
        inline istream &operator>>(istream &in,vector<t> &p)
        {
            for(auto & x : p)
                in >> x;
            return in;
        }
    struct custom_hash {
        static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }
        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
    };
}
using namespace forever;


void test_cases() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vii> h(n, vii(m-1)), v(n-1, vii(m));
    cin >> h >> v;
    if(k%2 == 1) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                cout << "-1 ";
            }
            cout << "\n";
        }    
        return;
    }
    
    int dp[n][m][((k>>1) + 1)];
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            dp[i][j][0] = 0;
        }
    }
    int temp;
    for(int kk = 1; kk <= (k>>1); kk++) {
        // for dist kk 
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                // from (i,j) to some pos in a path of len kk 
                temp = INT_MAX;
                if(j > 0) {
                    // left 
                    temp = dp[i][j-1][kk-1] + h[i][j-1];
                }
                if(j < m-1) {
                    // right 
                    temp = min(temp, dp[i][j+1][kk-1] + h[i][j]);
                }
                if(i > 0) {
                    // up 
                    temp = min(temp, dp[i-1][j][kk-1] + v[i-1][j]);
                }
                if(i < n-1) {
                    // down 
                    temp = min(temp, dp[i+1][j][kk-1] + v[i][j]);
                }
                dp[i][j][kk] = temp;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cout << (dp[i][j][(k>>1)]<<1) << " ";
        }
        cout << "\n";
    }
}


int32_t main()
{
	fio; 	
	#ifndef ONLINE_JUDGE
    	freopen("sip.txt","r",stdin);
   	    //freopen("sout.txt","w",stdout);
    #endif
    
    int t = 1;
    //cin >> t;
    for(int i = 0; i < t; i++) {
        test_cases();
    }
	return 0;
}