#include "bits/stdc++.h"
using namespace std;
#define int long long
#define INF (int)1e18

int dp[505][505][25];
int x[505][505];
int y[505][505];
int n, m, k;

bool valid(int i, int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m);
}

int solve(int i, int j, int rem)
{
    if (rem == 0) return 0;
    int &ret = dp[i][j][rem];
    if (ret != INF) return ret;
    if (valid(i, j + 1)) ret = min(ret, 2 * x[i][j] + solve(i, j + 1, rem - 1));
    if (valid(i, j - 1)) ret = min(ret, 2 * x[i][j - 1] + solve(i, j - 1, rem - 1));
    if (valid(i + 1, j)) ret = min(ret, 2 * y[i][j] + solve(i + 1, j, rem - 1));
    if (valid(i - 1, j)) ret = min(ret, 2 * y[i - 1][j] + solve(i - 1, j, rem - 1));
    return ret;
}

signed main()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m - 1; j++) {
            cin >> x[i][j];
        }
    }
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < m; j++) {
            cin >> y[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int it = 0; it <= k; it++) {
                dp[i][j][it] = INF;
            }
        }
    }
    if (k & 1) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cout << "-1 ";
            }
            cout << "\n";
        }
    }
    else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int h = solve(i, j, k / 2);
                cout << h << " ";
            }
            cout << "\n";
        }
    }
}
