#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define MOD 1000000007
#define sz5 100005
#define sz6 1000005
#define UP upper_bound
#define LB lower_bound
#define F first
#define S second
#define PI pair<int,int>
#define PL pair<ll,ll>
#define VI vector<int>
#define VL vector<ll>

ll dp[505][505][25];
ll hor[505][505];
ll ver[505][505];

int main() {
    FAST

    #ifndef ONLINE_JUDGE
        freopen("in", "r", stdin);
        // freopen("out", "w", stdout);
    #endif

    ll n,m,k,la,lb,lc,ld;
    cin>>n>>m>>k;

    for(la=0;la<n;la++){
        for(lb=1;lb<m;lb++)
            cin>>hor[la][lb];
    }
    for(la=1;la<n;la++){
        for(lb=0;lb<m;lb++)
            cin>>ver[la][lb];
    }

    if(k%2==1){
        for(la=0;la<n;la++){
            for(lb=0;lb<m;lb++)
                cout<<-1<<' ';
            cout<<endl;
        }
        return 0;
    }

    for(la=1;la<=k;la++){
        for(lb=0;lb<n;lb++){
            for(lc=0;lc<m;lc++)
                dp[lb][lc][la]=LLONG_MAX;
        }
    }

    for(la=2;la<=k;la+=2){
        for(lb=0;lb<n;lb++){
            for(lc=0;lc<m;lc++){
                ll lft=2*hor[lb][lc];
                ll rgt=2*hor[lb][lc+1];
                ll up=2*ver[lb][lc];
                ll dwn=2*ver[lb+1][lc];

                if(lc-1>=0)
                    dp[lb][lc][la] = min(dp[lb][lc][la], lft+dp[lb][lc-1][la-2]);
                if(lc+1<m)
                    dp[lb][lc][la] = min(dp[lb][lc][la], rgt+dp[lb][lc+1][la-2]);
                if(lb-1>=0)
                    dp[lb][lc][la] = min(dp[lb][lc][la], up+dp[lb-1][lc][la-2]);
                if(lb+1<n)
                    dp[lb][lc][la] = min(dp[lb][lc][la], dwn+dp[lb+1][lc][la-2]);
            }
        }
    }

    

    for(la=0;la<n;la++){
        for(lb=0;lb<m;lb++)
            cout<<dp[la][lb][k]<<' ';
        cout<<endl;
    }

    return 0;
}