// Problem: 1517_D. Explorer Space
// Time complexity: cubic
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
	static PrintWriter out;
	static Reader in;
	public static void main(String[] args) throws IOException {
		input_output();
		Main solver = new Main();
		solver.solve();
		out.close();
		out.flush();
	}

	static int INF = (int)1e9;
	static int MAXN = (int)4e5 + 5;
	static int MOD = (int)1e9+7;
	static int q, t, n, m, k;
	static double pi = Math.PI;

	void solve() throws IOException {
		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();

		int[][] right = new int[n][m],
			    left = new int[n][m],
			    up = new int[n][m],
			    down = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m-1; j++) {
				right[i][j] = in.nextInt();
				left[i][j+1] = right[i][j];
			}
		}
		for (int i = 0; i < n-1; i++) {
			for (int j = 0; j < m; j++) {
				down[i][j] = in.nextInt();
				up[i+1][j] = down[i][j];
			}
		}

		if (k%2 == 1) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					out.print("-1 ");
				}
				out.println();
			}
			return;
		}

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

		for (int step = 2; step <= k; step+=2) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (i != 0) {
						dp[i][j][step] = Math.min(dp[i][j][step], dp[i-1][j][step-2]+up[i][j]*2);
					}
					if (i != n-1) {
						dp[i][j][step] = Math.min(dp[i][j][step], dp[i+1][j][step-2]+down[i][j]*2);	
					}
					if (j != 0) {
						dp[i][j][step] = Math.min(dp[i][j][step], dp[i][j-1][step-2]+left[i][j]*2);
					}
					if (j != m-1) {
						dp[i][j][step] = Math.min(dp[i][j][step], dp[i][j+1][step-2]+right[i][j]*2);
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				out.print(dp[i][j][k]+" ");
			}
			out.println();
		}
	}

	static class Reader {
		private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public Reader() {
			this(System.in);
		}

		public Reader(InputStream is) {
			mIs = is;
		}

		public int read() {
			if (numChars == -1) {
				throw new InputMismatchException();

			}
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = mIs.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9') {
					throw new InputMismatchException();
				}
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9') {
					throw new InputMismatchException();
				}
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}
	static void input_output() throws IOException {
		File f = new File("in.txt");
		if (f.exists() && !f.isDirectory()) {
			in = new Reader(new FileInputStream("in.txt"));
		} else in = new Reader();
		f = new File("out.txt");
		if (f.exists() && !f.isDirectory()) {
			out = new PrintWriter(new File("out.txt"));
		} else out = new PrintWriter(System.out);
	}
}