#include<bits/stdc++.h>
#define ll int
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n, m, i, j, k = 0, t, w, flag, x, y, z, sum;
string s1, s2, s;
int main()
{
    FAST_IO;
    cin >> n >> m >> k;
    ll h[n + 1][m], l[n][m + 1];
    vector<vector<ll> >re ( n + 1, vector<ll> ( m + 1, 0 ) );
    vector<vector<ll> >temp ( n + 1, vector<ll> ( m + 1, 0 ) );

    for ( i = 1; i <= n; i++ )
        for ( j = 1; j < m; j++ )
            cin >> h[i][j];

    for ( i = 1; i < n; i++ )
        for ( j = 1; j <= m; j ++ )
            cin >> l[i][j];

    for ( t = 1; t <= k / 2; t++ )
    {
        for ( i = 1; i <= n; i++ )
        {
            for ( j = 1; j <= m; j++ )
            {
                temp[i][j] = ( int ) 1e9;;
                if ( i != n )
                    temp[i][j] = min ( temp[i][j], re[i + 1][j] + l[i][j] * 2 );
                if ( i != 1 )
                    temp[i][j] = min ( temp[i][j], re[i - 1][j] + l[i - 1][j] * 2 );
                if ( j != m )
                    temp[i][j] = min ( temp[i][j], re[i][j + 1] + h[i][j] * 2 );
                if ( j != 1 )
                    temp[i][j] = min ( temp[i][j], re[i][j - 1] + h[i][j - 1] * 2 );
            }
        }
        swap ( re, temp );
    }
    for ( i = 1; i <= n; cout << endl, i++ )
        for ( j = 1; j <= m; j++ )
        {
            if ( j > 1 ) cout << " ";
            cout << ( k % 2 ? -1 : re[i][j] );
        }

}