#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<time.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <deque>
#include <map>
#include <set>
#include <string>
#define ll long long
typedef long long LL;
typedef unsigned long long ULL;
//typedef long double ld;
using namespace std;
const int MAXN = 2e6 + 5000;
const long double eps = (1e-12);
const int logn = 21;
const double Pi = acos(-1.0);
const LL pp = 1000000000 + 9;
int lowbit(int x) { return x & (-x); }
#define MP(i,j) make_pair(i,j)
#define M(x) ((((x)%pp)+pp)%pp)
//#define int LL
#define P pair<int,int>
const int INF = 1e9;

int toright[505][505];
int todown[505][505];

int dx[5] = { 0,0,0,-1,1 };
int dy[5] = { 0,-1,1,0,0 };
int dp[505][505][25];

int getww(int x1, int y1, int x2, int y2) {
    if (x2 == x1 + 1) {
        return todown[x1][y1];
    }
    else if (x2 == x1 - 1) {
        return todown[x2][y1];
    }
    else if (y2 == y1 + 1) {
        return toright[x1][y1];
    }
    else if (y2 == y1 - 1) {
        return toright[x1][y2];
    }
    return -1;
}

signed main() {
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m - 1; j++) {
            scanf("%d", &toright[i][j]);
        }
    }
    for (int i = 1; i <= n - 1; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &todown[i][j]);
        }
    }
    if (k % 2 == 1) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                printf("-1 ");
            }
            printf("\n");
        }
    }
    else {
        k /= 2;

        for (int kk = 1; kk <= k; kk++) {
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    dp[i][j][kk] = INF;
                }
            }
        }

        for (int kk = 1; kk <= k; kk++) {
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    for (int l = 1; l <= 4; l++) {
                        int x = i + dx[l]; int y = j + dy[l];
                        if (x<1 || x>n || y<1 || y>m) continue;
                        int w = getww(i, j, x, y);
                        dp[i][j][kk] = min(dp[i][j][kk], w + dp[x][y][kk - 1]);
                    }
                }
            }
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                printf("%d ", dp[i][j][k] * 2);
            }
            printf("\n");
        }
    }


    return 0;
}