#include <bits/stdc++.h>
#include <iostream>
#include <set>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e9
#define optmise ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int dp[25][550][550];
int main()
{
    optmise;
    int n,m,k;
    cin >> n >> m >> k;
    int hor[n][m], ver[n][m];
    if(k%2 == 1){
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                cout << -1 << " ";
            }
            cout << endl;
        }
    } else {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m-1; ++j)
            {
                int a;
                cin >> a;
                hor[i][j] = a;
            }
        }

        for (int i = 0; i < n-1; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                int a;
                cin >> a;
                ver[i][j] = a;
            }
        }
        k /= 2;
        for (int l = 1; l <= k; ++l)
        {     
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < m; ++j)
                {
                    dp[l][i][j] = INF;
                    if(i > 0)
                        dp[l][i][j] = min(dp[l][i][j], dp[l-1][i-1][j] + ver[i-1][j]);
                    if(j > 0)
                        dp[l][i][j] = min(dp[l][i][j], dp[l-1][i][j-1] + hor[i][j-1]);
                    if(i < n-1)
                        dp[l][i][j] = min(dp[l][i][j], dp[l-1][i+1][j] + ver[i][j]);
                    if(j < m-1)
                        dp[l][i][j] = min(dp[l][i][j], dp[l-1][i][j+1] + hor[i][j]);
                }
            }
        }
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                cout << dp[k][i][j]*2 << " ";
            }
            cout << endl;
        }
    }
}
