#include <iostream>

int main()
{
    std::ios::sync_with_stdio(false);

    int height, width, steps;
    std::cin >> height >> width >> steps;

    const int MAX_WIDTH = 505;
    const int MAX_HEIGHT = 505;

    static int horizontal[MAX_HEIGHT][MAX_WIDTH];
    static int vertical[MAX_HEIGHT][MAX_WIDTH];

    for (int i = 0; i < height; ++i)
    {
        for (int j = 0; j < width - 1; ++j)
            std::cin >> horizontal[i][j];
    }

    for (int i = 0; i < height - 1; ++i)
    {
        for (int j = 0; j < width; ++j)
            std::cin >> vertical[i][j];
    }

    if (steps % 2 != 0)
    {
        for (int i = 0; i < height; ++i)
        {
            for (int j = 0; j < width; ++j)
            {
                if (j != 0)
                    std::cout << ' ';
                std::cout << "-1";
            }
            std::cout << std::endl;
        }

        return 0;
    }

    const int MAX_STEPS = 22;

    static int minLen[MAX_HEIGHT][MAX_WIDTH][MAX_STEPS];

    steps >>= 1;

    for (int currStep = 1; currStep <= steps; ++currStep)
    {
        for (int i = 0; i < height; ++i)
        {
            for (int j = 0; j < width; ++j)
            {
                int currValue = INT_MAX;

                if (i > 0)
                {
                    int v = minLen[i - 1][j][currStep - 1] + vertical[i - 1][j];
                    if (v < currValue)
                        currValue = v;
                }

                if (i < height - 1)
                {
                    int v = minLen[i + 1][j][currStep - 1] + vertical[i][j];
                    if (v < currValue)
                        currValue = v;
                }

                if (j > 0)
                {
                    int v = minLen[i][j - 1][currStep - 1] + horizontal[i][j - 1];
                    if (v < currValue)
                        currValue = v;
                }

                if (j < width - 1)
                {
                    int v = minLen[i][j + 1][currStep - 1] + horizontal[i][j];
                    if (v < currValue)
                        currValue = v;
                }

                minLen[i][j][currStep] = currValue;
            }
        }
    }

    for (int i = 0; i < height; ++i)
    {
        for (int j = 0; j < width; ++j)
        {
            if (j != 0)
                std::cout << ' ';
            std::cout << (minLen[i][j][steps] << 1);
        }
        std::cout << std::endl;
    }

    return 0;
}