/**
  *  Author: dhruv_gheewala
  *  Problem: D. Explorer Space
  *  Date:   23.04.2021
  *  Time:   22:29:46
**/

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

#ifndef DEBUG

#define fundri 108
#define debug(...) 1729
#define endl '\n'

#endif

#define int int64_t

typedef pair<int, int> pii;
typedef vector<int> vi;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

bool in_range(int x, int l, int r) {return l <= x && x <= r;}
template<typename H, typename ...T>void inp(H &head) {cin >> head;}
template<typename H, typename ...T>void inp(H &head, T &...tail) {cin >> head;inp(tail...);}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(T &x : a)in >> x; return in;}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.first >> a.second; return in;}

// Multi-Dimension Vector
// Usage: vec<n, data-type> dp(dimention-1, dimention-2, ..., dimention-n, default = data-type())
template<int D, typename T> struct vec : public vector<vec<D - 1, T>> {
    static_assert(D >= 1, "Vector dimensions must be greater than zero !!");
    template<typename... Args>
    vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)){}
};

template<typename T> struct vec<1, T> : public vector<T> {vec(int n = 0, T val = T()) : vector<T>(n, val){}};

const int inf = 1e15;
const bool testcases = false;

const bool ready = []() -> bool {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    return true;
}();

void solve(int tc);
int32_t main(int32_t argc, char **argv) {
    int TC = 1;
    if(testcases) cin >> TC;

    // Pre-Processing goes here...
    for(int tc = 1; tc <= TC; ++tc) {
        solve(tc);
        fundri;
    }
    exit(0);
}

typedef vector<vector<pii>> graph;
graph adj;
void add_edge(graph &a, int u, int v, int w = 1, bool dir = 0)
{
    a[u].push_back({v, w});
    if(!dir) a[v].push_back({u, w});
}

void clearAll(int n)
{
    adj.clear();
    adj.resize(n + 1);
}

int val(int x, int y, int n, int m) {return x * n + y;}
pair<int, int> val(int p, int n, int m) {return {(p - p % m) / n, p % m};}
bool valid(int x, int y, int n, int m) {return in_range(x, 0, n - 1) && in_range(y, 0, m - 1);}

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {-1, 0, 1, 0, 1, -1, -1, 1};
const vector<string> directions = {"L", "U", "R", "D", "DR", "DL", "UL", "UR"};

void solve(int tc) {
    int n, m, k;
    cin >> n >> m >> k;

    if(k & 1) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                cout << -1 << ' ';
            }
            cout << endl;
        }
        return;
    }

    int count = 0;
    vec<2, int> ind(n, m);
    vector<pii> rind(n * m + 10);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            ind[i][j] = count;
            rind[count] = {i, j};
            count++;
        }
    }

    clearAll(count);
    vec<3, int> dp(n, m, k + 1, inf);
    for(int i = 0; i < n; i++) {
        int x;
        for(int j = 1; j < m; j++) {
            cin >> x;
            add_edge(adj, ind[i][j], ind[i][j - 1], x);
            
            dp[i][j][1] = min(dp[i][j][1], x);
            dp[i][j - 1][1] = min(dp[i][j - 1][1], x);
            debug(i, j, i, j - 1);
        }
    }
    debug("done");

    for(int i = 1; i < n; i++) {
        int x;
        for(int j = 0; j < m; j++) {
            cin >> x;
            add_edge(adj, ind[i][j], ind[i - 1][j], x);

            dp[i][j][1] = min(dp[i][j][1], x);
            dp[i - 1][j][1] = min(dp[i - 1][j][1], x);
            debug(i, j, i - 1, j);
        }
    }
    debug("done");

    for(int i = 2; i <= k; i++) {
        for(int j = 0; j < n; j++) {
            for(int jj = 0; jj < m; jj++) {
                for(const auto &[v, w]: adj[ind[j][jj]]) {
                    const auto [cj, cjj] = rind[v];
                    dp[j][jj][i] = min(dp[j][jj][i], dp[cj][cjj][i - 1] + w);
                }
            }
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++)
            cout << 2 * dp[i][j][k / 2] << ' ';
        cout << endl;
    }
}