#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << (x) << endl
#define EPS 1e-9
#define PI acos(-1.0)
using namespace std;
void test() { cerr << endl; }
template <typename T, typename... Args>
void test(T x, Args... args) {
  cerr << x << " ";
  test(args...);
}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = (int)1e5 + 10;
const int MOD = (int)1e9 + 7;
const int INF = 1e9;
struct node {
  int x, y, k, d;
  bool operator< (const node& a) const {
    return d > a.d;
  }
};
void Main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> a(n, vector<int>(m-1));
  vector<vector<int>> b(m, vector<int>(n-1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m -1; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i + 1< n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> b[j][i];
    }
  }
  if (k % 2) {
    for (int i = 0; i < n; i++) {
      for(int j = 0; j < m; j++) {
        cout << -1 << " ";
      }
      cout << "\n";
    }
    return;
  }
  vector<vector<vector<int>>> dis(n, vector<vector<int>>(m, vector<int>(k/2+1, INF)));
  priority_queue<node> q;
  for (int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      q.push({i, j, 0, 0});
      dis[i][j][0] = 0;

    }
  }
  auto up = [&](int x, int y, int k,int d) {
    if (dis[x][y][k] > d) {
      q.push({x, y, k, d});
      dis[x][y][k] = d;
    }
  };
  while(!q.empty()) {
    node now = q.top();
    q.pop();
    int x = now.x;
    int y = now.y;
    int tmp_k = now.k;
    
    int d = now.d;
    if (d != dis[x][y][tmp_k] || tmp_k == k/2)
      continue;
    tmp_k++;
    if (x) {
      up(x - 1, y, tmp_k, d + b[y][x - 1]);
    }
    if (x + 1 < n) {
      up(x + 1, y, tmp_k, d + b[y][x]);
    }
    if (y) {
      up(x, y - 1, tmp_k, d + a[x][y - 1]);
    }
    if (y + 1 < m) {
      up(x, y + 1, tmp_k, d + a[x][y]);
    }
  }
  for (int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      cout << dis[i][j][k/2] * 2 << " ";
    }
    cout << "\n";
  }
}
int main() {
  #ifdef LOCAL
    freopen("in.txt", "r", stdin);
  #else
    ios_base:: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  #endif
  int T = 1;
  // cin >> T;
  for (int ca = 1; ca <= T; ca++) {
   // cout << "Case #" << ca << ": ";
    Main();
  }
  return 0;
}