#include <bits/stdc++.h>
using namespace std;

const int kMaxN = 505,  kMaxK = 21, kInf = 0x3f3f3f3f;
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, -1, 0, 1 };
int n, m, k, w[4][kMaxN][kMaxN], dp[kMaxK][kMaxN][kMaxN];

int resolve(int k, int x, int y) {
  if (~dp[k][x][y]) return dp[k][x][y];
  if (k == 0) return dp[k][x][y] = 0;
  int &ans = dp[k][x][y];
  ans = kInf;
  for (int d = 0; d < 4; ++d) {
    int nx = x + dx[d], ny = y + dy[d];
    if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
    ans = min(ans, w[d][x][y] + resolve(k - 1, nx, ny));
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  memset(dp, 0xff, sizeof dp);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1, x; j < m; ++j) {
      cin >> x;
      w[1][i][j + 1] = w[3][i][j] = x;
    }
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1, x; j <= m; ++j) {
      cin >> x;
      w[0][i + 1][j] = w[2][i][j] = x;
    }
  }
  if (k & 1) {
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j)
        cout << -1 << " \n"[j == m];
    return 0;
  }
  k >>= 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << (resolve(k, i, j) * 2) << " \n"[j == m];
    }
  }
  return 0;
}