#include "bits/stdc++.h"
using namespace std;
#define int long long
#define eb emplace_back
#define mp make_pair
typedef pair<int,int> pii;
#define f first
#define s second

#ifdef local
#define debug(x,label) cerr<<"DEBUG "<<label<<" "<<x<<'\n';
#else
#define debug(x,label);
#endif

#define min(a,b) ((a<b)?a:b)
#define max(a,b) ((a>b)?a:b)

//const int mod=1000000007;

int edgs[505][505],edgf[505][505],kekw[505][505][11];
int xx[4]={-1,-1,1,1};
int yy[4]={-1,1,-1,1};

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int n,m,k,ans;
  cin>>n>>m>>k;
  if((k%2)==1){
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        cout<<"-1";
        if(j+1<m)cout<<' ';
        else cout<<'\n';
      }
    }
    return 0;
  }
  k/=2;
  for(int i=0;i<n;i++){
    for(int j=0;j<m-1;j++){
      cin>>edgs[i][j];
    }
  }
  for(int i=0;i<n-1;i++){
    for(int j=0;j<m;j++){
      cin>>edgf[i][j];
    }
  }
  for(int kk=1;kk<=k;kk++){
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        kekw[i][j][kk]=1e9;
        if(i+1<n)kekw[i][j][kk]=min(edgf[i][j]+kekw[i+1][j][kk-1],kekw[i][j][kk]);
        if(j+1<m)kekw[i][j][kk]=min(edgs[i][j]+kekw[i][j+1][kk-1],kekw[i][j][kk]);
        if(i>0)kekw[i][j][kk]=min(edgf[i-1][j]+kekw[i-1][j][kk-1],kekw[i][j][kk]);
        if(j>0)kekw[i][j][kk]=min(edgs[i][j-1]+kekw[i][j-1][kk-1],kekw[i][j][kk]);
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cout<<2*kekw[i][j][k];
      if(j+1<m)cout<<' ';
    }
    cout<<'\n';
  }
  return 0;
}
/*

*/
