#include <bits/stdc++.h>
using namespace std;
#define dd double
#define ll long long int
#define light                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define pb push_back
#define mkp make_pair
#define pi pair<ll, ll>
#define pii pair<ll, pi>
#define fi first
#define sc second
ll INF = 1e18 + 5;
ll mod = 998244353;

bool safe_2_visit(int n, int m, int i, int j)
{
    if (0 <= i && i < n && 0 <= j && j < m)
        return true;
    return false;
}

void solve(int n, int m, int k, vector<vector<int>> &i_j1j2, vector<vector<int>> &i1i2_j)
{
    vector<vector<vector<int>>> dp(n, vector<vector<int>>(m, vector<int>((k / 2) + 1, INT_MAX))); // dp[i][j][k]

    // Initializing dp's lowest subproblem (if no moves then cost = 0)
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            dp[i][j][0] = 0;

    // Solving in bottom up manner from k = 0 to k = k
    for (int l = 2; l <= k; l += 2)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
            {
                int w = safe_2_visit(n, m, i - 1, j) ? 2 * i1i2_j[i - 1][j] + dp[i - 1][j][(l - 2) / 2] : INT_MAX;
                int x = safe_2_visit(n, m, i, j - 1) ? 2 * i_j1j2[i][j - 1] + dp[i][j - 1][(l - 2) / 2] : INT_MAX;
                int y = safe_2_visit(n, m, i + 1, j) ? 2 * i1i2_j[i][j] + dp[i + 1][j][(l - 2) / 2] : INT_MAX;
                int z = safe_2_visit(n, m, i, j + 1) ? 2 * i_j1j2[i][j] + dp[i][j + 1][(l - 2) / 2] : INT_MAX;

                dp[i][j][l / 2] = min(min(w, x), min(y, z));
            }

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

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("otpt.txt", "w", stdout);
#endif
    light;

    ll n, m, k;
    cin >> n >> m >> k;
    if (k % 2 != 0)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
                cout << -1 << ' ';
            cout << endl;
        }
        return 0;
    }
    vector<vector<int>> i_j1j2(n, vector<int>(m - 1));
    vector<vector<int>> i1i2_j(n - 1, vector<int>(m));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m - 1; j++)
            cin >> i_j1j2[i][j];
    for (int i = 0; i < n-1; i++)
        for (int j = 0; j < m; j++)
            cin >> i1i2_j[i][j];
    solve(n, m, k, i_j1j2, i1i2_j);
}