#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
ll arr[505][505];
ll arr1[504][505];
int n,m,k;
bool vis[505][505][12];
bool valid(int x,int y)
{
    if(x<=0 || y<=0 || x>n || y>m ) return false;
    return true;
}
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int rx,ry;
ll dp[505][505][12];
ll dfs(int x,int y,int step)
{
   // cout<<x<<" "<<y<<" "<<step<<endl;
    if(step==0)
    {
        return 0;
    }
    if(vis[x][y][step]) return dp[x][y][step];
    ll res=1e16;
    for(int i=0;i<4;i++)
    {
        int nx=dx[i]+x;
        int ny=dy[i]+y;
        //cout<<nx<<" "<<ny<<endl;
        //getchar();
        if(valid(nx,ny))
        {
            if(i==0)
            {
                res=min(res,arr[nx][ny]+dfs(nx,ny,step-1));
            }
            else if(i==2)
            {
                res=min(res,arr[x][y]+dfs(nx,ny,step-1));
            }
            else if(i==1)
            {
                res=min(res,arr1[x][y]+dfs(nx,ny,step-1));
            }
            else
            {
                res=min(res,arr1[nx][ny]+dfs(nx,ny,step-1));
            }
        }
    }
    vis[x][y][step]=1;
    return dp[x][y][step]=res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin>>n>>m>>k)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<m;j++)
            {
                cin>>arr[i][j];
                //arr[i][j]=1e6;
            }
        }
        for(int i=1;i<n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                cin>>arr1[i][j];
                //arr[i][j]=1e6;
            }
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                rx=i;
                ry=j;
                ll req=dfs(i,j,k/2);
                if(k%2==1)
                {
                    req=-1;
                }
                else req=req*2LL;
                cout<<req<<" ";
            }
            cout<<"\n";
        }

    }
    return 0;
}
