#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define print(v,n) for(i=0;i<n;i++) cout<<v[i]<<" ";
#define No cout<<"NO"<<endl;return
#define Yes cout<<"YES"<<endl;return
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
#define PI 3.14159265   ;
ll mod =1e9+7;
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i*i <= n; i = i + 6)
        if (n%i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll powe(ll x, ll y) {
    ll res = 1;
    while (y > 0) {
        if (y & 1) res =( res * x)%mod;
        y = y >> 1;
        x = (x * x)%mod;
    }
    return res;
}
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
unsigned long long power(unsigned long long x, int y, int p)
{
    unsigned long long res = 1; // Initialize result
 
    x = x % p; // Update x if it is more than or
    while (y > 0) 
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n,int p)
{
    return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n,int r, int p)
{
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
    unsigned long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;
 
    return (fac[n] * modInverse(fac[r], p) % p
            * modInverse(fac[n - r], p) % p)
           % p;
}

ll dp[501][501][21];
ll ans[501][501];
int a[501][501];
map<pair<ll,ll>,ll> vis;
map<ll,ll> cnt;
ll n,m,k;
ll row[501][501];
ll col[501][501];
bool isValid(ll i,ll j)
{
    if(i>=0 && i<n && j>=0 && j<m) return true;
    return false;
}
ll sol(ll i,ll j,ll k2)
{
    if(k2==0) return 0;
    //if(vis[{i,j}]) return;
    if(dp[i][j][k2]!=-1) return dp[i][j][k2];
    ll k1=LLONG_MAX;
   // vis[{i,j}]++;
    if(isValid(i,j+1) ) k1=min(k1,row[i][j]+sol(i,j+1,k2-1));
    if(isValid(i,j-1) ) k1=min(k1,row[i][j-1]+sol(i,j-1,k2-1));
    if(isValid(i+1,j)) k1=min(k1,col[i][j]+sol(i+1,j,k2-1));
    if(isValid(i-1,j) ) k1=min(k1,col[i-1][j]+sol(i-1,j,k2-1));

    return dp[i][j][k2]=k1;
    
}
void solve()
{
    ll i, x, y, j, h, w, k1, k2,k3,q;
    cin>>n>>m>>k;
    if(k%2)
    {
        f(i,0,n)
        {
            f(j,0,m)
            {
                cout<<-1<<" ";

            }
            cout<<ee;
        }
        return;
    }
    k/=2;
    memset(dp,-1,sizeof(dp));
    memset(ans,-1,sizeof(ans));
    for(i=0;i<n;i++)
    {
        for(j=0;j<m-1;j++)
        {
            cin>>row[i][j];
        }
    }
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>col[i][j];
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            k1=sol(i,j,k);
            ans[i][j]=k1;
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cout<<2*ans[i][j]<<" ";
        }
        cout<<ee;
    }
}

int main() {
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif
    fast;
    
    ll i, j, l, k, t, n;
    t=1;
    for (i = 1; i <= t; i++)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
    }
}
// 