#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define ROF(i,l,r) for(int i=l;i>=r;i--)
#define lson k<<1,l,mid
#define rson k<<1|1,mid+1,r
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define sss(str) scanf("%s",str+1)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int mod=1e9+7;
const int INF=2e9;
const double eps=1e-8;
const double pi=acos(-1);
template <class T>
inline void read(T &x) {
    char c;x = 1;
    while ((c = getchar()) < '0' || c > '9') if (c == '-') x = -1;
    T res = c - '0';
    while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
    x *= res;
}
int n,m;
char str[N];
int f[N];
int g1[550][550],g2[550][550];
LL dp[550][550][25];
LL D[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int getEdge(int x,int y,int l)
{
    if(l==0) if(x>1) return g2[x-1][y];
    if(l==1) if(x<n) return g2[x][y];
    if(l==2) if(y>1) return g1[x][y-1];
    if(l==3) if(y<m) return g1[x][y];
    return INF;
}
void solve(int cas)
{
    int k;
    rrr(n,m,k);
    FOR(i,1,n){
        FOR(j,1,m-1){
            r(g1[i][j]);
        }
    }
    FOR(i,1,n-1){
        FOR(j,1,m){
            r(g2[i][j]);
        }
    }
    if(k&1){
        FOR(i,1,n){
            FOR(j,1,m) cout<<-1<<' ';
            cout<<endl;
        }
        return ;
    }
    FOR(i,1,n){
        FOR(j,1,m){
            int minn=INF;
            FOR(l,0,3){
                minn=min(minn,getEdge(i,j,l));
            }
            dp[i][j][2]=minn*2;
        }
    }
    for(int kk=4;kk<=k;kk+=2){
        FOR(i,1,n){
            FOR(j,1,m){
                LL minn=INF;
                FOR(l,0,3){
                    int x=i+D[l][0];
                    int y=j+D[l][1];
                    if(x<1||x>n||y<1||y>m) continue;
                    minn=min(minn,2*getEdge(i,j,l)+dp[x][y][kk-2]);
                }
                dp[i][j][kk]=minn;
            }
        }
    }
    FOR(i,1,n){
        FOR(j,1,m) cout<<dp[i][j][k]<<' ';
        cout<<endl;
    }
}
int main()
{
//    init();
    int t;
//    r(t);
    t=1;
    FOR(i,1,t){
        solve(i);
    }
    return 0;
}
