import java.io.*;
import java.util.*;
import java.math.*;

public class D {
	static byte[] buf = new byte[1<<26];
    static int bp = -1;

	public static void main(String[] args) throws IOException {

		/**/
		DataInputStream in = new DataInputStream(System.in);
		/*/
		DataInputStream in = new DataInputStream(new FileInputStream("src/d.in"));
		/**/

		in.read(buf, 0, 1<<26);

		int n = nni();
		int m = nni();
		int k = nni();

		if (k%2==1) {
			for (int i = 0; i < n; ++i) {
				StringBuilder ans = new StringBuilder();
				String sp = "";
				for (int j = 0; j < m; ++j) {
					ans.append(sp+"-1");
					sp = " ";
				}
				System.out.println(ans);
			}
			return;
		}

		int[][] lr = new int[n][m-1];
		int[][] ud = new int[n-1][m];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m-1; ++j) {
				lr[i][j] = nni();
			}
		}
		for (int i = 0; i < n-1; ++i) {
			for (int j = 0; j < m; ++j) {
				ud[i][j] = nni();
			}
		}

		int[][][] ans = new int[k/2+1][n][m];

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				for (int q = 1; q <= k/2; ++q) {
					ans[q][i][j] = 123456789;
				}
			}
		}

		for (int uq = 0; uq < k/2; ++uq) {
			for (int ui = 0; ui < n; ++ui) {
				for (int uj = 0; uj < m; ++uj) {
					int w = ans[uq][ui][uj];
					if (ui>0 && w+ud[ui-1][uj]<ans[uq+1][ui-1][uj]) {
						ans[uq+1][ui-1][uj] = w+ud[ui-1][uj];
					}
					if (ui<n-1 && w+ud[ui][uj]<ans[uq+1][ui+1][uj]) {
						ans[uq+1][ui+1][uj] = w+ud[ui][uj];
					}
					if (uj>0 && w+lr[ui][uj-1]<ans[uq+1][ui][uj-1]) {
						ans[uq+1][ui][uj-1] = w+lr[ui][uj-1];
					}
					if (uj<m-1 && w+lr[ui][uj]<ans[uq+1][ui][uj+1]) {
						ans[uq+1][ui][uj+1] = w+lr[ui][uj];
					}
				}
			}
		}

		for (int i = 0; i < n; ++i) {
			StringBuilder as = new StringBuilder();
			String sp = "";
			for (int j = 0; j < m; ++j) {
				as.append(sp+ans[k/2][i][j]*2);
				sp = " ";
			}
			System.out.println(as);
		}
	}

	public static int nni() {
        int ret = 0;
        byte b = buf[++bp];
        while (true) {
            ret = ret*10+b-'0';
            b = buf[++bp];
            if (b<'0'||b>'9') {
            	while (buf[bp+1]=='\r'||buf[bp+1]=='\n'||buf[bp+1]==' ') {++bp;}
            	break;
            }
        }
        return ret;
    }
}


import java.util.*;
import java.io.*;

public class D
{

	static FastIO f;
	static long ve[][], he[][];

	public static void main(String args[]) throws IOException
	{
		f = new FastIO();

		int n = f.ni(), m = f.ni(), k = f.ni(), i, j;
		ve = new long[n-1][];
		he = new long[n][];

		long[][] ans = new long[n][m], pans = new long[n][m], temp;

		for(i = 0; i < n; i++)
			he[i] = f.nla(m-1);

		for(i = 0; i < n-1; i++)
			ve[i] = f.nla(m);

		if(k%2 == 1)
		{
			for(i = 0; i < n; i++)
				Arrays.fill(ans[i], -1L);
		}
		else
		{
			k /= 2;

			while(k-->0)
			{
				for(i = 0; i < n; i++)
				{
					for(j = 0; j < m; j++)
					{
						ans[i][j] = Integer.MAX_VALUE;

						if(i != 0)
							ans[i][j] = Math.min(ans[i][j], pans[i-1][j] + 2*edge(i, j, i-1, j));

						if(i != n-1)
							ans[i][j] = Math.min(ans[i][j], pans[i+1][j] + 2*edge(i, j, i+1, j));

						if(j != 0)
							ans[i][j] = Math.min(ans[i][j], pans[i][j-1] + 2*edge(i, j, i, j-1));

						if(j != m-1)
							ans[i][j] = Math.min(ans[i][j], pans[i][j+1] + 2*edge(i, j, i, j+1));
					}
				}

				// f.err(k + "\n");
				// errorprint(ans, n, m);

				temp = pans;
				pans = ans;
				ans = temp;
			}

			temp = pans;
			pans = ans;
			ans = temp;
		}

		for(i = 0; i < n; i++)
		{
			for(j = 0; j < m; j++)
			{
				f.out(ans[i][j] + " ");
			}

			f.out("\n");
		}

		f.flush();
	}

	public static void errorprint(long[][] p, int n, int m) throws IOException
	{
		int i, j;

		for(i = 0; i < n; i++)
		{
			for(j = 0; j < m; j++)
			{
				f.err(p[i][j] + " ");
			}

			f.err("\n");
		}

		f.err("\n");
	}

	public static long edge(int i, int j, int x, int y)
	{
		if(i == x)
			return he[i][Math.min(j, y)];
		else
			return ve[Math.min(i, x)][j];
	}

	public static class FastIO
	{
		BufferedReader br;
		BufferedWriter bw, be;
		StringTokenizer st;

		public FastIO()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
			bw = new BufferedWriter(new OutputStreamWriter(System.out));
			be = new BufferedWriter(new OutputStreamWriter(System.err));
			st = new StringTokenizer("");
		}

		private void read() throws IOException
		{
			st = new StringTokenizer(br.readLine());
		}

		public String ns() throws IOException
		{
			while(!st.hasMoreTokens())
				read();
			return st.nextToken();
		}

		public int ni() throws IOException
		{
			return Integer.parseInt(ns());
		}

		public long nl() throws IOException
		{
			return Long.parseLong(ns());
		}

		public float nf() throws IOException
		{
			return Float.parseFloat(ns());
		}

		public double nd() throws IOException
		{
			return Double.parseDouble(ns());
		}

		public char nc() throws IOException
		{
			return ns().charAt(0);
		}

		public int[] nia(int n) throws IOException
		{
			int[] a = new int[n];
			for(int i = 0; i < n; i++)
				a[i] = ni();

			return a;
		}

		public long[] nla(int n) throws IOException
		{
			long[] a = new long[n];
			for(int i = 0; i < n; i++)
				a[i] = nl();

			return a;
		}

		public char[] nca() throws IOException
		{
			return ns().toCharArray();
		}

		public void out(String s) throws IOException
		{
			bw.write(s);
		}

		public void flush() throws IOException
		{
			bw.flush();
			be.flush();
		}

		public void err(String s) throws IOException
		{
			be.write(s);
		}
	}
}


import java.util.*;
import java.io.*;

public class D {
	public static int dir[][]={{-1,0},{1,0},{0,-1},{0,1}};
	public static void main(String[] args) {
//		Scanner sc=new Scanner(System.in);
		FastScanner sc = new FastScanner();
		FastOutput out = new FastOutput(System.out);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int k=sc.nextInt();
		int ans[][][]=new int[n][m][11];
		int arr[][]=new int[n*m][4];
		for(int i=0;i<n;i++){
			for(int j=0;j<m-1;j++){
				int x=sc.nextInt();
				arr[i*m+j][3]=x;
				arr[i*m+j+1][2]=x;
			}
		}
		for(int i=0;i<n-1;i++){
			for(int j=0;j<m;j++){
				int x=sc.nextInt();
				arr[i*m+j][1]=x;
				arr[(i+1)*m+j][0]=x;
			}
		}
		if(k%2==1){
			for(int i=0;i<n;i++){
				StringBuilder sb=new StringBuilder("");
				for(int j=0;j<m;j++){
					ans[i][j][10]=-1;
					sb.append(ans[i][j][10]+" ");
				}
				out.println(sb.toString());
			}
		}else{

			for(int ceng=1;ceng<=k/2;ceng++){
				for(int i=0;i<n;i++){
					for(int j=0;j<m;j++){
						ans[i][j][ceng]=Integer.MAX_VALUE/3;
						for(int dr=0;dr<4;dr++){
							int nx=i+dir[dr][0];
							int ny=j+dir[dr][1];
							if(nx<n&&ny<m&&nx>=0&&ny>=0){
								ans[i][j][ceng]=Math.min(ans[i][j][ceng], ans[nx][ny][ceng-1]+arr[i*m+j][dr]);
							}
						}
					}
				}
			}
			for(int i=0;i<n;i++){
				StringBuilder sb=new StringBuilder("");
				for(int j=0;j<m;j++){
					sb.append(ans[i][j][k/2]*2+" ");
				}
				out.println(sb.toString());
			}
		}
		out.close();
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readIntArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	static class FastOutput implements AutoCloseable, Closeable, Appendable {
		private static final int THRESHOLD = 1 << 13;
		private final Writer os;
		private StringBuilder cache = new StringBuilder(THRESHOLD * 2);

		public FastOutput append(CharSequence csq) {
			cache.append(csq);
			return this;
		}

		public FastOutput append(CharSequence csq, int start, int end) {
			cache.append(csq, start, end);
			return this;
		}

		private void afterWrite() {
			if (cache.length() < THRESHOLD) {
				return;
			}
			flush();
		}

		public FastOutput(Writer os) {
			this.os = os;
		}

		public FastOutput(OutputStream os) {
			this(new OutputStreamWriter(os));
		}

		public FastOutput append(char c) {
			cache.append(c);
			afterWrite();
			return this;
		}

		public FastOutput append(int c) {
			cache.append(c);
			afterWrite();
			return this;
		}

		public FastOutput append(String c) {
			cache.append(c);
			afterWrite();
			return this;
		}

		public FastOutput println(String c) {
			return append(c).println();
		}

		public FastOutput println() {
			return append(System.lineSeparator());
		}

		public FastOutput flush() {
			try {
				os.append(cache);
				os.flush();
				cache.setLength(0);
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
			return this;
		}

		public void close() {
			flush();
			try {
				os.close();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
		public String toString() {
			return cache.toString();
		}
	}
}


import java.io.*;
import java.util.*;

public final class Solution {

    static PrintWriter out = new PrintWriter(System.out);
    static FastReader in = new FastReader();
    static long mod = (long) 1e9 + 7;
    static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)};

    //6 3
    //2 3 10 7 5 14
    //1 6
    //2 4
    //3 5

    public static void main(String[] args) {

        int n = i();
        int m = i();
        int k = i();

        int[][] a = new int[n][m - 1];
        for (int i = 0; i < n; i++) {
            a[i] = input(m - 1);
        }

        int[][] b = new int[n - 1][m];
        for (int i = 0; i < n - 1; i++) {
            b[i] = input(m);
        }

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

        int[][][] f = new int[n][m][k / 2 + 1];

        for (int s = 1; s <= k / 2; s++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    int ans = -1;

                    if (j > 0) {
                        ans = f[i][j - 1][s - 1] + a[i][j - 1];
                    }
                    if (i > 0) {
                        int t = f[i - 1][j][s - 1] + b[i - 1][j];
                        ans = ans == -1 ? t : Math.min(ans, t);
                    }
                    if (i < n - 1) {
                        int t = f[i + 1][j][s - 1] + b[i][j];
                        ans = ans == -1 ? t : Math.min(ans, t);
                    }
                    if (j < m - 1) {
                        int t = f[i][j + 1][s - 1] + a[i][j];
                        ans = ans == -1 ? t : Math.min(ans, t);
                    }

                    f[i][j][s] = ans;
                }
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                out.print(f[i][j][k / 2] * 2 + " ");
            }
            out.println();
        }
        out.flush();
    }

    static int sd(long i) {
        int d = 0;
        while (i > 0) {
            d += i % 10;
            i = i / 10;
        }
        return d;
    }

    static Set<Integer> getFactors(int x) {
        Set<Integer> res = new HashSet<>();

        if (x <= 3) {
            res.add(x);
        } else {
            int t = x;
            for (int f = 2; f <= x / 2; f++) {
                if (t == 1) {
                    break;
                }
                if (t % f == 0) {
                    res.add(f);
                    while (t % f == 0) {
                        t = t / f;
                    }
                }
            }

            if (t > 1) {
                res.add(t);
            }
        }
        return res;
    }

    static int lower(long A[], long x) {
        int l = -1, r = A.length;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (A[m] >= x) {
                r = m;
            } else {
                l = m;
            }
        }
        return r;
    }

    static int upper(long A[], long x) {
        int l = -1, r = A.length;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (A[m] <= x) {
                l = m;
            } else {
                r = m;
            }
        }
        return l;
    }

    static void swap(int A[], int a, int b) {
        int t = A[a];
        A[a] = A[b];
        A[b] = t;
    }

    static int lowerBound(int A[], int low, int high, int x) {
        if (low > high) {
            if (x >= A[high]) {
                return A[high];
            }
        }

        int mid = (low + high) / 2;

        if (A[mid] == x) {
            return A[mid];
        }

        if (mid > 0 && A[mid - 1] <= x && x < A[mid]) {
            return A[mid - 1];
        }

        if (x < A[mid]) {
            return lowerBound(A, low, mid - 1, x);
        }

        return lowerBound(A, mid + 1, high, x);
    }

    static long pow(long a, long b) {
        long pow = 1;
        long x = a;
        while (b != 0) {
            if ((b & 1) != 0) {
                pow = (pow * x) % mod;
            }
            x = (x * x) % mod;
            b /= 2;
        }
        return pow;
    }

    static boolean isPrime(long N) {
        if (N <= 1) {
            return false;
        }
        if (N <= 3) {
            return true;
        }
        if (N % 2 == 0 || N % 3 == 0) {
            return false;
        }
        for (int i = 5; i * i <= N; i = i + 6) {
            if (N % i == 0 || N % (i + 2) == 0) {
                return false;
            }
        }
        return true;
    }

    static void print(char A[]) {
        for (char c : A) {
            out.print(c);
        }
        out.println();
    }

    static void print(boolean A[]) {
        for (boolean c : A) {
            out.print(c + " ");
        }
        out.println();
    }

    static void print(int A[]) {
        for (int c : A) {
            out.print(c + " ");
        }
        out.println();
    }

    static void print(long A[]) {
        for (long i : A) {
            out.print(i + " ");
        }
        out.println();

    }

    static void print(List<Integer> A) {
        for (int a : A) {
            out.print(a + " ");
        }
    }

    static int i() {
        return in.nextInt();
    }

    static long l() {
        return in.nextLong();
    }

    static String s() {
        return in.nextLine();
    }

    static int[] input(int N) {
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }
        return A;
    }

    static long[] inputLong(int N) {
        long A[] = new long[N];
        for (int i = 0; i < A.length; i++) {
            A[i] = in.nextLong();
        }
        return A;
    }

    static int GCD(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            return GCD(b, a % b);
        }
    }

    static long GCD(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return GCD(b, a % b);
        }
    }

}

class SegmentTree {

    long[] t;

    public SegmentTree(int n) {
        t = new long[n + n];
        Arrays.fill(t, Long.MIN_VALUE);
    }

    public long get(int i) {
        return t[i + t.length / 2];
    }

    public void add(int i, long value) {
        i += t.length / 2;
        t[i] = value;
        for (; i > 1; i >>= 1) {
            t[i >> 1] = Math.max(t[i], t[i ^ 1]);
        }
    }

    // max[a, b]
    public long max(int a, int b) {
        long res = Long.MIN_VALUE;
        for (a += t.length / 2, b += t.length / 2; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1) {
            if ((a & 1) != 0) {
                res = Math.max(res, t[a]);
            }
            if ((b & 1) == 0) {
                res = Math.max(res, t[b]);
            }
        }
        return res;
    }
}

class Pair {

    int i, j;

    Pair(int i, int j) {
        this.i = i;
        this.j = j;
    }
}

class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

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

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }

}


//package round718;

import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Queue;

public class D2 {
	InputStream is;
	FastWriter out;
	String INPUT = "";//2 5 9 9 9 9 9 8 8 8 8 5 6 7 8 9";

	void solve()
	{
		int n = ni(), m = ni(), K = ni();
		int[][] a = new int[2*n+1][2*m+1];
		for(int i = 0;i < n;i++){
			int[] u = na(m-1);
			for(int j = 0;j < m-1;j++){
				a[2*i][2*j+1] = u[j];
			}
		}
		for(int i = 0;i < n-1;i++){
			int[] u = na(m);
			for(int j = 0;j < m;j++){
				a[2*i+1][2*j] = u[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[K/2+1][n][m];
		int[] dr = {1, 0, -1, 0};
		int[] dc = {0, 1, 0, -1};
		for(int i = 1;i <= K/2;i++){
			for(int j = 0;j < n;j++){
				for(int k = 0;k < m;k++){
					dp[i][j][k] = Integer.MAX_VALUE;
					for(int l = 0;l < 4;l++){
						int jj = j + dr[l], kk = k + dc[l];
						if(jj >= 0 && jj < n && kk >= 0 && kk < m){
							dp[i][j][k] = Math.min(dp[i][j][k], dp[i-1][jj][kk] + a[j+jj][k+kk]);
						}
					}
				}
			}
		}

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

	void run() throws Exception
	{
//		int n = 500, m = 500;
//		Random gen = new Random();
//		StringBuilder sb = new StringBuilder();
//		sb.append(n + " ");
//		sb.append(n + " ");
//		sb.append(20 + " ");
//		for (int i = 0; i < n; i++) {
//			for(int j = 0;j < m-1;j++) {
//				sb.append(gen.nextInt(200000) + " ");
//			}
//		}
//		for (int i = 0; i < n-1; i++) {
//			for(int j = 0;j < m;j++) {
//				sb.append(gen.nextInt(200000) + " ");
//			}
//		}
//		INPUT = sb.toString();

		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new FastWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new D2().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private long[] nal(int n)
	{
		long[] a = new long[n];
		for(int i = 0;i < n;i++)a[i] = nl();
		return a;
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[][] nmi(int n, int m) {
		int[][] map = new int[n][];
		for(int i = 0;i < n;i++)map[i] = na(m);
		return map;
	}

	private int ni() { return (int)nl(); }

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	public static class FastWriter
	{
		private static final int BUF_SIZE = 1<<13;
		private final byte[] buf = new byte[BUF_SIZE];
		private final OutputStream out;
		private int ptr = 0;

		private FastWriter(){out = null;}

		public FastWriter(OutputStream os)
		{
			this.out = os;
		}

		public FastWriter(String path)
		{
			try {
				this.out = new FileOutputStream(path);
			} catch (FileNotFoundException e) {
				throw new RuntimeException("FastWriter");
			}
		}

		public FastWriter write(byte b)
		{
			buf[ptr++] = b;
			if(ptr == BUF_SIZE)innerflush();
			return this;
		}

		public FastWriter write(char c)
		{
			return write((byte)c);
		}

		public FastWriter write(char[] s)
		{
			for(char c : s){
				buf[ptr++] = (byte)c;
				if(ptr == BUF_SIZE)innerflush();
			}
			return this;
		}

		public FastWriter write(String s)
		{
			s.chars().forEach(c -> {
				buf[ptr++] = (byte)c;
				if(ptr == BUF_SIZE)innerflush();
			});
			return this;
		}

		private static int countDigits(int l) {
			if (l >= 1000000000) return 10;
			if (l >= 100000000) return 9;
			if (l >= 10000000) return 8;
			if (l >= 1000000) return 7;
			if (l >= 100000) return 6;
			if (l >= 10000) return 5;
			if (l >= 1000) return 4;
			if (l >= 100) return 3;
			if (l >= 10) return 2;
			return 1;
		}

		public FastWriter write(int x)
		{
			if(x == Integer.MIN_VALUE){
				return write((long)x);
			}
			if(ptr + 12 >= BUF_SIZE)innerflush();
			if(x < 0){
				write((byte)'-');
				x = -x;
			}
			int d = countDigits(x);
			for(int i = ptr + d - 1;i >= ptr;i--){
				buf[i] = (byte)('0'+x%10);
				x /= 10;
			}
			ptr += d;
			return this;
		}

		private static int countDigits(long l) {
			if (l >= 1000000000000000000L) return 19;
			if (l >= 100000000000000000L) return 18;
			if (l >= 10000000000000000L) return 17;
			if (l >= 1000000000000000L) return 16;
			if (l >= 100000000000000L) return 15;
			if (l >= 10000000000000L) return 14;
			if (l >= 1000000000000L) return 13;
			if (l >= 100000000000L) return 12;
			if (l >= 10000000000L) return 11;
			if (l >= 1000000000L) return 10;
			if (l >= 100000000L) return 9;
			if (l >= 10000000L) return 8;
			if (l >= 1000000L) return 7;
			if (l >= 100000L) return 6;
			if (l >= 10000L) return 5;
			if (l >= 1000L) return 4;
			if (l >= 100L) return 3;
			if (l >= 10L) return 2;
			return 1;
		}

		public FastWriter write(long x)
		{
			if(x == Long.MIN_VALUE){
				return write("" + x);
			}
			if(ptr + 21 >= BUF_SIZE)innerflush();
			if(x < 0){
				write((byte)'-');
				x = -x;
			}
			int d = countDigits(x);
			for(int i = ptr + d - 1;i >= ptr;i--){
				buf[i] = (byte)('0'+x%10);
				x /= 10;
			}
			ptr += d;
			return this;
		}

		public FastWriter write(double x, int precision)
		{
			if(x < 0){
				write('-');
				x = -x;
			}
			x += Math.pow(10, -precision)/2;
			//		if(x < 0){ x = 0; }
			write((long)x).write(".");
			x -= (long)x;
			for(int i = 0;i < precision;i++){
				x *= 10;
				write((char)('0'+(int)x));
				x -= (int)x;
			}
			return this;
		}

		public FastWriter writeln(char c){
			return write(c).writeln();
		}

		public FastWriter writeln(int x){
			return write(x).writeln();
		}

		public FastWriter writeln(long x){
			return write(x).writeln();
		}

		public FastWriter writeln(double x, int precision){
			return write(x, precision).writeln();
		}

		public FastWriter write(int... xs)
		{
			boolean first = true;
			for(int x : xs) {
				if (!first) write(' ');
				first = false;
				write(x);
			}
			return this;
		}

		public FastWriter write(long... xs)
		{
			boolean first = true;
			for(long x : xs) {
				if (!first) write(' ');
				first = false;
				write(x);
			}
			return this;
		}

		public FastWriter writeln()
		{
			return write((byte)'\n');
		}

		public FastWriter writeln(int... xs)
		{
			return write(xs).writeln();
		}

		public FastWriter writeln(long... xs)
		{
			return write(xs).writeln();
		}

		public FastWriter writeln(char[] line)
		{
			return write(line).writeln();
		}

		public FastWriter writeln(char[]... map)
		{
			for(char[] line : map)write(line).writeln();
			return this;
		}

		public FastWriter writeln(String s)
		{
			return write(s).writeln();
		}

		private void innerflush()
		{
			try {
				out.write(buf, 0, ptr);
				ptr = 0;
			} catch (IOException e) {
				throw new RuntimeException("innerflush");
			}
		}

		public void flush()
		{
			innerflush();
			try {
				out.flush();
			} catch (IOException e) {
				throw new RuntimeException("flush");
			}
		}

		public FastWriter print(byte b) { return write(b); }
		public FastWriter print(char c) { return write(c); }
		public FastWriter print(char[] s) { return write(s); }
		public FastWriter print(String s) { return write(s); }
		public FastWriter print(int x) { return write(x); }
		public FastWriter print(long x) { return write(x); }
		public FastWriter print(double x, int precision) { return write(x, precision); }
		public FastWriter println(char c){ return writeln(c); }
		public FastWriter println(int x){ return writeln(x); }
		public FastWriter println(long x){ return writeln(x); }
		public FastWriter println(double x, int precision){ return writeln(x, precision); }
		public FastWriter print(int... xs) { return write(xs); }
		public FastWriter print(long... xs) { return write(xs); }
		public FastWriter println(int... xs) { return writeln(xs); }
		public FastWriter println(long... xs) { return writeln(xs); }
		public FastWriter println(char[] line) { return writeln(line); }
		public FastWriter println(char[]... map) { return writeln(map); }
		public FastWriter println(String s) { return writeln(s); }
		public FastWriter println() { return writeln(); }
	}

	public void trnz(int... o)
	{
		for(int i = 0;i < o.length;i++)if(o[i] != 0)System.out.print(i+":"+o[i]+" ");
		System.out.println();
	}

	// print ids which are 1
	public void trt(long... o)
	{
		Queue<Integer> stands = new ArrayDeque<>();
		for(int i = 0;i < o.length;i++){
			for(long x = o[i];x != 0;x &= x-1)stands.add(i<<6|Long.numberOfTrailingZeros(x));
		}
		System.out.println(stands);
	}

	public void tf(boolean... r)
	{
		for(boolean x : r)System.out.print(x?'#':'.');
		System.out.println();
	}

	public void tf(boolean[]... b)
	{
		for(boolean[] r : b) {
			for(boolean x : r)System.out.print(x?'#':'.');
			System.out.println();
		}
		System.out.println();
	}

	public void tf(long[]... b)
	{
		if(INPUT.length() != 0) {
			for (long[] r : b) {
				for (long x : r) {
					for (int i = 0; i < 64; i++) {
						System.out.print(x << ~i < 0 ? '#' : '.');
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}

	public void tf(long... b)
	{
		if(INPUT.length() != 0) {
			for (long x : b) {
				for (int i = 0; i < 64; i++) {
					System.out.print(x << ~i < 0 ? '#' : '.');
				}
			}
			System.out.println();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


// Don't place your source in a package
import javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;

// Please name your class Main
public class Main {
    static FastScanner fs=new FastScanner();
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int Int() {
            return Integer.parseInt(next());
        }

        long Long() {
            return Long.parseLong(next());
        }

        String Str(){
            return next();
        }
    }

    public static void main (String[] args) throws java.lang.Exception {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        int T=1;
        for(int t=0;t<T;t++){
            int n=Int(),m=Int(),k=Int();
            List<int[]>g[]=new ArrayList[n*m+1];
            for(int i=0;i<g.length;i++){
                g[i]=new ArrayList<>();
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m-1;j++){
                    int w=Int();
                    int u=i*m+j;
                    int v=i*m+(j+1);
                    g[u].add(new int[]{v,w});
                    g[v].add(new int[]{u,w});
                }
            }

            for(int i=0;i<n-1;i++){
                for(int j=0;j<m;j++){
                    int w=Int();
                    int u=i*m+j;
                    int v=(i+1)*m+j;
                    g[u].add(new int[]{v,w});
                    g[v].add(new int[]{u,w});
                }
            }

            Solution sol=new Solution(out);
            sol.solution(n,m,k,g);
        }
        out.close();

    }

    public static int Int(){
        return fs.Int();
    }
    public static long Long(){
        return fs.Long();
    }
    public static String Str(){
        return fs.Str();
    }

}

class Solution{
    PrintWriter out;
    public Solution(PrintWriter out){
        this.out=out;
    }

    List<int[]>g[];
    int n,m;
    long INF=10000000000000000l;
    int curr=-1,curc=-1;
    long mn=Long.MAX_VALUE;
    long dp[][];
    public void solution(int n,int m,int k,List<int[]>g[]){
        //edge : 4 directions.
        this.n=n;
        this.m=m;
        long res[][]=new long[n][m];
        if(k%2==1){
            for(int i=0;i<n;i++){
                Arrays.fill(res[i],-1);
            }
            print(res);
            return;
        }
        this.g=g;
        dp=new long[n*m+1][k/2+2];
        for(int i=0;i<dp.length;i++){
            Arrays.fill(dp[i],-1);
        }

        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int id=i*m+j;
                dfs(id,k/2);
            }
        }

        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int id=i*m+j;
                res[i][j]=dp[id][k/2];
            }
        }
        print(res);
    }

    public long dfs(int id,int cnt){
        if(cnt==0){
            return 0;
        }
        if(dp[id][cnt]!=-1)return dp[id][cnt];

        int r=id/m;
        int c=id%m;
        long res=Long.MAX_VALUE;
        for(int p[]:g[id]){
            int next=p[0],w=p[1];
            res=Math.min(res,w*2+dfs(next,cnt-1));
        }
        dp[id][cnt]=res;
        return res;

    }

    public int dis(int x1,int y1,int x2,int y2){
        return Math.abs(x1-x2)+Math.abs(y1-y2);
    }

    public void print(long A[][]){
        for(int i=0;i<A.length;i++){
            for(int j=0;j<A[0].length;j++){
                out.print(A[i][j]+" ");
            }
            out.println();
        }
    }

}

class Solution1{
    PrintWriter out;
    public Solution1(PrintWriter out){
        this.out=out;
    }

    public void solution(int A[]){

    }

}

/*
                             ;\
                            |' \
         _                  ; : ;
        / `-.              /: : |
       |  ,-.`-.          ,': : |
       \  :  `. `.       ,'-. : |
        \ ;    ;  `-.__,'    `-.|
         \ ;   ;  :::  ,::'`:.  `.
          \ `-. :  `    :.    `.  \
           \   \    ,   ;   ,:    (\
            \   :., :.    ,'o)): ` `-.
           ,/,' ;' ,::"'`.`---'   `.  `-._
         ,/  :  ; '"      `;'          ,--`.
        ;/   :; ;             ,:'     (   ,:)
          ,.,:.    ; ,:.,  ,-._ `.     \""'/
          '::'     `:'`  ,'(  \`._____.-'"'
             ;,   ;  `.  `. `._`-.  \\
             ;:.  ;:       `-._`-.\  \`.
              '`:. :        |' `. `\  ) \
      -hrr-      ` ;:       |    `--\__,'
                   '`      ,'
                        ,-'

                      free bug dog
*/


import java.io.*;
import java.util.*;

import java.math.*;
import java.awt.Point;

public class Main {
    static final long MOD = 1000000007L;
    //static final long MOD2 = 1000000009L;
    //static final long MOD = 998244353L;
    //static final long INF = 500000000000L;
    static final int INF =   1000000005;
    static final int NINF = -1000000005;
    //static final long NINF = -1000000000000000000L;
    static FastScanner sc;
    static PrintWriter pw;
    static final int[][] dirs = {{-1,0},{1,0},{0,-1},{0,1}};

    static final int MO = 1200;

    public static void main(String[] args) {
        sc = new FastScanner();
        pw = new PrintWriter(System.out);

        int N = sc.ni();
        int M = sc.ni();
        int K = sc.ni();
        int[][] LR = new int[N][M-1];
        for (int i = 0; i < N; i++) {
            LR[i] = sc.intArray(M-1,0);
        }
        int[][] UD = new int[N-1][M];
        for (int i = 0; i < N-1; i++) {
            UD[i] = sc.intArray(M,0);
        }

        if (K%2==0) {
            int T = K/2;
            int[][] dist = new int[N][M];

            for (int step = 1; step <= T; step++) {
                int[][] newDist = new int[N][M];
                for (int i = 0; i < N; i++) {
                    for (int j = 0; j < M; j++) {
                        newDist[i][j] = INF;

                        //up
                        if (i > 0) {
                            newDist[i][j] = Math.min(newDist[i][j],UD[i-1][j]+dist[i-1][j]);
                        }

                        //down
                        if (i < N-1) {
                            newDist[i][j] = Math.min(newDist[i][j],UD[i][j]+dist[i+1][j]);
                        }

                        //left
                        if (j > 0) {
                            newDist[i][j] = Math.min(newDist[i][j],LR[i][j-1]+dist[i][j-1]);
                        }

                        //right
                        if (j < M-1) {
                            newDist[i][j] = Math.min(newDist[i][j],LR[i][j]+dist[i][j+1]);
                        }
                    }
                }
                dist = newDist;
            }

            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
                    pw.print((2*dist[i][j]) + " ");
                }
                pw.println();
            }
        } else {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
                    pw.print("-1 ");
                }
                pw.println();
            }
        }
        pw.close();
    }

    public static void sort(int[] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            int temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr);
    }

    public static void sort(long[] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            long temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr);
    }

    //Sort an array (immune to quicksort TLE)
    public static void sort(int[][] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            int[] temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr, new Comparator<int[]>() {
            @Override
            public int compare(int[] a, int[] b) {
                int ablock = a[0]/MO;
                int bblock = b[0]/MO;
                if (ablock != bblock)
                    return ablock-bblock;
                else
                    return a[1]-b[1];
            }
        });
    }

    public static void sort(long[][] arr) {
        Random rgen = new Random();
        for (int i = 0; i < arr.length; i++) {
            int r = rgen.nextInt(arr.length);
            long[] temp = arr[i];
            arr[i] = arr[r];
            arr[r] = temp;
        }
        Arrays.sort(arr, new Comparator<long[]>() {
            @Override
            public int compare(long[] a, long[] b) {
                if (a[0] > b[0])
                    return 1;
                else if (a[0] < b[0])
                    return -1;
                else
                    return 0;
                //Ascending order.
            }
        });
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in), 32768);
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int ni() {
            return Integer.parseInt(next());
        }

        int[][] graph(int N, int[][] edges) {
            int[][] graph = new int[N][];
            int[] sz = new int[N];
            for (int[] e: edges) {
                sz[e[0]] += 1;
                sz[e[1]] += 1;
            }
            for (int i = 0; i < N; i++) {
                graph[i] = new int[sz[i]];
            }
            int[] cur = new int[N];
            for (int[] e: edges) {
                graph[e[0]][cur[e[0]]] = e[1];
                graph[e[1]][cur[e[1]]] = e[0];
                cur[e[0]] += 1;
                cur[e[1]] += 1;
            }
            return graph;
        }

        int[] intArray(int N, int mod) {
            int[] ret = new int[N];
            for (int i = 0; i < N; i++)
                ret[i] = ni()+mod;
            return ret;
        }

        long nl() {
            return Long.parseLong(next());
        }

        long[] longArray(int N, long mod) {
            long[] ret = new long[N];
            for (int i = 0; i < N; i++)
                ret[i] = nl()+mod;
            return ret;
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter pw;
    static _Scanner sc;

    public static void main(String[] args) throws Exception {
        sc = new _Scanner(System.in);
        pw = new PrintWriter(System.out);
        //long startTime = System.currentTimeMillis();
        //int t = sc.nextInt();
        int t = 1;
        while (t-- > 0) {
            solve();
        }
        pw.flush();
        //System.out.println("time: " + (System.currentTimeMillis() - startTime));
    }

    private static void solve() throws Exception {
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();

        int[][] h = new int[n][m - 1];
        int[][] v = new int[n - 1][m];

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m - 1; ++j) {
                h[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i < n - 1; ++i) {
            for (int j = 0; j < m; ++j) {
                v[i][j] = sc.nextInt();
            }
        }

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

        k = k / 2;

        long[][] d = new long[n][m];
        for (int ki = 0; ki < k; ++ki) {
            long[][] dk = new long[n][m];
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    long val = Integer.MAX_VALUE;

                    if (j < m - 1) {
                        val = Math.min(val, d[i][j + 1] + h[i][j]);
                    }

                    if (i < n - 1) {
                        val = Math.min(val, d[i + 1][j] + v[i][j]);
                    }

                    if (j > 0) {
                        val = Math.min(val, d[i][j - 1] + h[i][j - 1]);
                    }

                    if (i > 0) {
                        val = Math.min(val, d[i - 1][j] + v[i - 1][j]);
                    }

                    dk[i][j] = val;
                }
            }
            d = dk;
        }

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (j > 0) {
                    pw.print(" ");
                }
                pw.print(d[i][j] * 2);
            }
            pw.println();
        }
    }

    static class Shuffle {
        static void run(int[] in) {
            for (int i = 0; i < in.length; i++) {
                int idx = (int) (Math.random() * in.length);
                int tmp = in[i];
                in[i] = in[idx];
                in[idx] = tmp;
            }
        }

        static void run(long[] in) {
            for (int i = 0; i < in.length; i++) {
                int idx = (int) (Math.random() * in.length);
                long tmp = in[i];
                in[i] = in[idx];
                in[idx] = tmp;
            }
        }

        static <T> void run(List<T> in) {
            for (int i = 0; i < in.size(); i++) {
                int idx = (int) (Math.random() * in.size());
                T tmp = in.get(i);
                in.set(i, in.get(idx));
                in.set(idx, tmp);
            }
        }
    }

    static class _Scanner {
        StringTokenizer st;
        BufferedReader br;

        _Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        _Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        String nextToken() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int[] intArr(int n) throws IOException {
            int[] in = new int[n];
            for (int i = 0; i < n; i++) in[i] = nextInt();
            return in;
        }

        long[] longArr(int n) throws IOException {
            long[] in = new long[n];
            for (int i = 0; i < n; i++) in[i] = nextLong();
            return in;
        }

        int[] intArrSorted(int n) throws IOException {
            int[] in = new int[n];
            for (int i = 0; i < n; i++) in[i] = nextInt();
            Shuffle.run(in);
            Arrays.sort(in);
            return in;
        }

        long[] longArrSorted(int n) throws IOException {
            long[] in = new long[n];
            for (int i = 0; i < n; i++) in[i] = nextLong();
            Shuffle.run(in);
            Arrays.sort(in);
            return in;
        }

        Integer[] IntegerArr(int n) throws IOException {
            Integer[] in = new Integer[n];
            for (int i = 0; i < n; i++) in[i] = nextInt();
            return in;
        }

        Long[] LongArr(int n) throws IOException {
            Long[] in = new Long[n];
            for (int i = 0; i < n; i++) in[i] = nextLong();
            return in;
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(nextToken());
        }

        char nextChar() throws IOException {
            return nextToken().charAt(0);
        }

        long nextLong() throws IOException {
            return Long.parseLong(nextToken());
        }

        boolean ready() throws IOException {
            return br.ready();
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DExplorerSpace solver = new DExplorerSpace();
        solver.solve(1, in, out);
        out.close();
    }

    static class DExplorerSpace {
        static final int oo = 1000000000;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
            int[][] right = new int[n][m - 1];
            int[][] down = new int[n - 1][m];

            for (int i = 0; i < n; i++) right[i] = in.readIntArray(m - 1);
            for (int i = 0; i + 1 < n; i++) down[i] = in.readIntArray(m);
            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[k / 2 + 1][n][m];

            for (int r = 1; 2 * r <= k; r++) {
                for (int i = 0; i < n; i++) Arrays.fill(dp[r][i], oo);
                for (int i = 0; i < n; i++)
                    for (int j = 0; j < m - 1; j++) {
                        int cost = right[i][j];
                        dp[r][i][j] = Integer.min(dp[r][i][j], dp[r - 1][i][j + 1] + cost);
                        dp[r][i][j + 1] = Integer.min(dp[r][i][j + 1], dp[r - 1][i][j] + cost);
                    }

                for (int i = 0; i + 1 < n; i++)
                    for (int j = 0; j < m; j++) {
                        int cost = down[i][j];
                        dp[r][i][j] = Integer.min(dp[r][i][j], dp[r - 1][i + 1][j] + cost);
                        dp[r][i + 1][j] = Integer.min(dp[r][i + 1][j], dp[r - 1][i][j] + cost);
                    }
            }

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

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
            writer.print('\n');
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = readInt();
            }
            return array;
        }

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

        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 int readInt() {
            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) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        static int n;
        static int m;
        static int steps;
        static long[][] distJ;
        static long[][] distI;
        static long[][][] memo;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            steps = in.nextInt();
            memo = new long[n][m][steps];
            distJ = new long[n][m - 1];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m - 1; j++) {
                    distJ[i][j] = in.nextLong();
                }
            }
            distI = new long[n - 1][m];
            for (int i = 0; i < n - 1; i++) {
                for (int j = 0; j < m; j++) {
                    distI[i][j] = in.nextLong();
                }
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (steps % 2 != 0) {
                        out.print(-1 + " ");
                    } else {
                        out.print(2 * lowestCost(i, j, steps / 2) + " ");
                    }
                }
                out.println();
            }
        }

        private long lowestCost(int i, int j, int distance) {
            if (distance == 0) {
                return 0;
            }
            if (memo[i][j][distance] > 0) {
                return memo[i][j][distance];
            }

            long minDist = Long.MAX_VALUE;
            //j + 1 and j -1
            if (j < m - 1) {
                // move forward on j
                minDist = Math.min(minDist, distJ[i][j] + lowestCost(i, j + 1, distance - 1));
            }
            if (j > 0) {
                // move backward on j
                minDist = Math.min(minDist, distJ[i][j - 1] + lowestCost(i, j - 1, distance - 1));
            }

            if (i < n - 1) {
                // move forward on i
                minDist = Math.min(minDist, distI[i][j] + lowestCost(i + 1, j, distance - 1));
            }
            if (i > 0) {
                // move backward on i
                minDist = Math.min(minDist, distI[i - 1][j] + lowestCost(i - 1, j, distance - 1));
            }

            //memoize
            memo[i][j][distance] = minDist;
            return minDist;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println() {
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

        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 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 boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.PrintWriter;
import java.util.*;

public class D {

    static Scanner sc;
    static PrintWriter out;

    public static void main(String[] args) throws Exception {

        sc = new Scanner(System.in);
        out = new PrintWriter(System.out);
        //int t = sc.nextInt();
        for(int i=0; i<1; i++) {
            solve();
        }
        out.flush();
    }

    static void solve() {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[][] a = new int[n][m-1];
        int[][] b = new int[n-1][m];
        for(int i=0 ;i<n; i++) {
            for(int j=0; j<m-1; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for(int i=0 ;i<n-1; i++) {
            for(int j=0; j<m; j++) {
                b[i][j] = sc.nextInt();
            }
        }

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

        int[][] prev = new int[n][m];
        k /= 2;
        for(int l=0; l<k; l++) {
            int[][] next = new int[n][m];
            for(int i=0; i<n; i++) {
                for(int j=0; j<m; j++) {
                    next[i][j] = Integer.MAX_VALUE;
                    if(i>0) {
                        next[i][j] = Math.min(next[i][j], prev[i-1][j] + b[i-1][j]);
                    }
                    if(i+1<n) {
                        next[i][j] = Math.min(next[i][j], prev[i+1][j] + b[i][j]);
                    }
                    if(j>0) {
                        next[i][j] = Math.min(next[i][j], prev[i][j-1] + a[i][j-1]);
                    }
                    if(j+1<m) {
                        next[i][j] = Math.min(next[i][j], prev[i][j+1] + a[i][j]);
                    }
                }
            }
            prev = next;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (j > 0)
                    out.print(" ");
                out.print(prev[i][j] * 2);
            }
            out.println();
        }

    }

}


import java.util.*;
import java.io.*;
public class EdE {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[0];
	public static MyScanner sc;
    public static PrintWriter out;
    static long[][][] paths;
    static long[] powers501;
	public static void main(String[] havish) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		out = new PrintWriter(System.out);
 		int n = sc.nextInt();
 		int m = sc.nextInt();
 		int k = sc.nextInt();
 		paths = new long[n+1][m+1][4]; //up down left right;
 		powers501 = new long[5];
 		powers501[0] = 1;
 		for(int j = 1;j<5;j++){
 			powers501[j] = 501L*powers501[j-1];
 		}
 		long[][][]dp = new long[n+1][m+1][k/2+2];
 		for(int i = 1;i<=n;i++){
 			for(int j = 1;j<=m-1;j++){
 				int val = sc.nextInt();
 				paths[i][j][3] = val;
 				paths[i][j+1][2] = val;
// 				paths.put(powers501[3]*i + powers501[2]*j + powers501[1]*i + powers501[0]*(j+1), val);
// 				paths.put(powers501[3]*i + powers501[2]*(j+1) + powers501[1]*i + powers501[0]*j, val);
 			}
 		}
 		for(int i = 1;i<=n-1;i++){
 			for(int j = 1;j<=m;j++){
 				int val = sc.nextInt();
// 				paths.put(powers501[3]*(i+1) + powers501[2]*j + powers501[1]*i + powers501[0]*j, val);
// 				paths.put(powers501[3]*i + powers501[2]*j + powers501[1]*(i+1) + powers501[0]*j, val);
 				paths[i][j][1] = val;
 				paths[i+1][j][0] = val;

 			}
 		}
 		for(int j = 1;j<=n;j++){
 			for(int i = 1;i<=m;i++){
 				Arrays.fill(dp[j][i],  Integer.MAX_VALUE);
 				dp[j][i][0] = 0;
 			}
 		}
 		for(int steps = 1;steps<k/2+2;steps++){
 			for(int i = 1;i<=n;i++){
 				for(int j = 1;j<=m;j++){
 					if (i-1 > 0) {
 						dp[i][j][steps] = Math.min(dp[i-1][j][steps-1] + getVal(i, j, i-1, j), dp[i][j][steps]);
 					}
 					if (j-1 > 0) {
 						dp[i][j][steps] = Math.min(dp[i][j-1][steps-1] + getVal(i, j, i, j-1), dp[i][j][steps]);
 					}

 					if (i+1 <= n) {
 						dp[i][j][steps] = Math.min(dp[i+1][j][steps-1] + getVal(i, j, i+1, j), dp[i][j][steps]);
 					}
 					if (j+1 <= m) {
 						dp[i][j][steps] = Math.min(dp[i][j+1][steps-1] + getVal(i, j, i, j+1), dp[i][j][steps]);
 					}
 				}
 			}
 		}
 		if (k%2 == 1){
 			for(int j = 1;j<=n;j++){
 				for(int s = 1;s<=m;s++){
 					out.print(-1 + " ");
 				}
 				out.println();
 			}
 		}
 		else{
 			for(int j = 1;j<=n;j++){
 				for(int s = 1;s<=m;s++){
 					out.print(dp[j][s][k/2]*2L + " ");
 				}
 				out.println();
 			}
 		}

 		out.close();
 	}
	public static long getVal(int x1, int y1, int x2, int y2) {
		if (x2 == x1+1)
			return paths[x1][y1][1];
		else if (x1 == x2+1)
			return paths[x1][y1][0];
		else if (y2 == y1 + 1)
			return paths[x1][y1][3];
		else
			return paths[x1][y1][2];
	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
	static void verdict(boolean a){
        out.println(a ? "YES" : "NO");
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is


import java.util.Scanner;

public class D {
    static long[][][] dp;
    static int[][] hor, ver;
    static int n, m;
    static int[][] dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

    public static boolean isValid (int row, int col) {
        return row >= 0 && col >= 0 && row < n && col < m;
    }

    public static void minCost (int row, int col, int k) {
        if (k == 0)
            return;
        if (k == 2) {
            long min = Long.MAX_VALUE;
            for (int i = 0; i < 4; i++) {
                if (isValid(row + dir[i][0], col + dir[i][1])) {
                    if ((row + dir[i][0]) == row) {
                        if ((col + dir[i][1]) > col) {
                            min = Math.min(min, hor[row][col]);
                        } else {
                            min = Math.min(min, hor[row][col - 1]);
                        }
                    } else {
                        if ((row + dir[i][0]) > row) {
                            min = Math.min(min, ver[row][col]);
                        } else {
                            min = Math.min(min, ver[row - 1][col]);
                        }
                    }
                }
            }
            dp[row][col][k] = 2 * min;
            return;
        }
        if (dp[row][col][k] != Long.MAX_VALUE)
            return;
        long min = Long.MAX_VALUE;
        for (int i = 0; i < 4; i++) {
            if (isValid(row + dir[i][0], col + dir[i][1])) {
                if (k >= 4) {
                    minCost(row + dir[i][0], col + dir[i][1], k - 2);
                    int edge = 0;
                    if ((row + dir[i][0]) == row) {
                        if ((col + dir[i][1]) > col) {
                            edge = hor[row][col];
                        } else {
                            edge = hor[row][col - 1];
                        }
                    } else {
                        if ((row + dir[i][0]) > row) {
                            edge = ver[row][col];
                        } else {
                            edge = ver[row - 1][col];
                        }
                    }
                    min = Math.min(min, 2 * edge + dp[row + dir[i][0]][col + dir[i][1]][k - 2]);
                }
            }
        }
        dp[row][col][k] = min;
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        m = input.nextInt();
        int k = input.nextInt();
        hor = new int[n][m - 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m - 1; j++) {
                hor[i][j] = input.nextInt();
            }
        }
        ver = new int[n - 1][m];
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < m; j++) {
                ver[i][j] = input.nextInt();
            }
        }
        if (k % 2 != 0) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    System.out.print(-1 + " ");
                }
                System.out.println("");
            }
        } else {
            dp = new long[n][m][k + 1];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    for (int x = 0; x <= k; x++) {
                        dp[i][j][x] = Long.MAX_VALUE;
                    }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    minCost(i, j, k);
                    System.out.print(dp[i][j][k] + " ");
                }
                System.out.println("");
            }
        }

        input.close();
    }
}


//Utilities
import java.io.*;
import java.util.*;

public class Main {
	static int n, m, k;
	static int[][] horW, verW;
	static int[][][] dp = new int[505][505][15];

	public static void main(String[] args) throws IOException {
		for (int i = 0; i < 505; i++) {
			for (int j = 0; j < 505; j++) {
				for (int k = 0; k < 15; k++) {
					dp[i][j][k] = -1;
				}
			}
		}
		n = in.iscan(); m = in.iscan(); k =in.iscan();
		horW = new int[n+1][m]; verW = new int[n][m+1];
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m-1; j++) {
				horW[i][j] = in.iscan();
			}
		}
		for (int i = 1; i <= n-1; i++) {
			for (int j = 1; j <= m; j++) {
				verW[i][j] = in.iscan();
			}
		}
		int min = Integer.MAX_VALUE;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (k % 2 == 1) {
					out.print(-1 + " ");
					continue;
				}
				out.print(dfs(i, j, k/2) * 2 + " ");
			}
			out.println();
		}
		out.close();
	}

	static int dfs(int r, int c, int k) {
		if (dp[r][c][k] != -1) {
			return dp[r][c][k];
		}
		if (k == 0) {
			return dp[r][c][k] = 0;
		}
		int min = Integer.MAX_VALUE;
		if (r - 1 >= 1) {
			min = Math.min(min, verW[r-1][c] + dfs(r-1, c, k-1));
		}
		if (r + 1 <= n) {
			min = Math.min(min, verW[r][c] + dfs(r+1, c, k-1));
		}
		if (c - 1 >= 1) {
			min = Math.min(min, horW[r][c-1] + dfs(r, c-1, k-1));
		}
		if (c + 1 <= m) {
			min = Math.min(min, horW[r][c] + dfs(r, c+1, k-1));
		}
		return dp[r][c][k] = min;
	}

	static INPUT in = new INPUT(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	private static class INPUT {

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar, numChars;

		public INPUT (InputStream stream) {
			this.stream = stream;
		}

		public INPUT (String file) throws IOException {
			this.stream = new FileInputStream (file);
		}

		public int cscan () throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read (buf);
			}

			if (numChars == -1)
				return numChars;

			return buf[curChar++];
		}

		public int iscan () throws IOException {
			int c = cscan (), sgn = 1;

			while (space (c))
				c = cscan ();

			if (c == '-') {
				sgn = -1;
				c = cscan ();
			}

			int res = 0;

			do {
				res = (res << 1) + (res << 3);
				res += c - '0';
				c = cscan ();
			}
			while (!space (c));

			return res * sgn;
		}

		public String sscan () throws IOException {
			int c = cscan ();

			while (space (c))
				c = cscan ();

			StringBuilder res = new StringBuilder ();

			do {
				res.appendCodePoint (c);
				c = cscan ();
			}
			while (!space (c));

			return res.toString ();
		}

		public double dscan () throws IOException {
			int c = cscan (), sgn = 1;

			while (space (c))
				c = cscan ();

			if (c == '-') {
				sgn = -1;
				c = cscan ();
			}

			double res = 0;

			while (!space (c) && c != '.') {
				if (c == 'e' || c == 'E')
					return res * UTILITIES.fast_pow (10, iscan ());

				res *= 10;
				res += c - '0';
				c = cscan ();
			}

			if (c == '.') {
				c = cscan ();
				double m = 1;

				while (!space (c)) {
					if (c == 'e' || c == 'E')
						return res * UTILITIES.fast_pow (10, iscan ());

					m /= 10;
					res += (c - '0') * m;
					c = cscan ();
				}
			}

			return res * sgn;
		}

		public long lscan () throws IOException {
			int c = cscan (), sgn = 1;

			while (space (c))
				c = cscan ();

			if (c == '-') {
				sgn = -1;
				c = cscan ();
			}

			long res = 0;

			do {
				res = (res << 1) + (res << 3);
				res += c - '0';
				c = cscan ();
			}
			while (!space (c));

			return res * sgn;
		}

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

	public static class UTILITIES {

		static final double EPS = 10e-6;

		public static int lower_bound (int[] arr, int x) {
			int low = 0, high = arr.length, mid = -1;

			while (low < high) {
				mid = (low + high) / 2;

				if (arr[mid] >= x)
					high = mid;
				else
					low = mid + 1;
			}

			return low;
		}

		public static int upper_bound (int[] arr, int x) {
			int low = 0, high = arr.length, mid = -1;

			while (low < high) {
				mid = (low + high) / 2;

				if (arr[mid] > x)
					high = mid;
				else
					low = mid + 1;
			}

			return low;
		}

		public static long gcd (long a, long b) {
			return b == 0 ? a : gcd (b, a % b);
		}

		public static long lcm (long a, long b) {
			return a * b / gcd (a, b);
		}

		public static long fast_pow_mod (long b, long x, int mod) {
			if (x == 0) return 1;
			if (x == 1) return b;
			if (x % 2 == 0) return fast_pow_mod (b * b % mod, x / 2, mod) % mod;

			return b * fast_pow_mod (b * b % mod, x / 2, mod) % mod;
		}

		public static int fast_pow (int b, int x) {
			if (x == 0) return 1;
			if (x == 1) return b;
			if (x % 2 == 0) return fast_pow (b * b, x / 2);

			return b * fast_pow (b * b, x / 2);
		}

		public static long choose (long n, long k) {
			k = Math.min (k, n - k);
			long val = 1;

			for (int i = 0; i < k; ++i)
				val = val * (n - i) / (i + 1);

			return val;
		}

		public static long permute (int n, int k) {
			if (n < k) return 0;
			long val = 1;

			for (int i = 0; i < k; ++i)
				val = (val * (n - i));

			return val;
		}
	}
}


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {

    public static void deal(int n,int m,int k,int[][] d1,int[][] d2) {
        if(k % 2 == 1) {
            for(int i=0;i<n;i++) {
                for(int j=0;j<m;j++) {
                    System.out.print("-1 ");
                }
                System.out.println();
            }
            return;
        }
        int[][][] dp = new int[k/2+1][n][m];
        for(int i=0;i<k/2;i++) {
            for(int j=0;j<n;j++) {
                for(int l=0;l<m;l++) {
                    int min = Integer.MAX_VALUE;
                    if(j>0) min = Math.min(min,d2[j-1][l]+dp[i][j-1][l]);
                    if(j<n-1) min = Math.min(min,d2[j][l]+dp[i][j+1][l]);
                    if(l>0) min = Math.min(min,d1[j][l-1]+dp[i][j][l-1]);
                    if(l<m-1) min = Math.min(min,d1[j][l]+dp[i][j][l+1]);
                    dp[i+1][j][l] = min;
                }
            }
        }
        for(int i=0;i<n;i++) {
            for(int j=0;j<m;j++) {
                System.out.print(dp[k/2][i][j]*2);
                System.out.print(" ");
            }
            System.out.println();
        }
    }
    public static void main(String[] args) {
        MyScanner scanner = new MyScanner();
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        int[][] d1 = new int[n][m-1];
        int[][] d2 = new int[n-1][m];
        for(int i=0;i<n;i++) {
            for(int j=0;j<m-1;j++) {
                d1[i][j] = scanner.nextInt();
            }
        }
        for(int i=0;i<n-1;i++) {
            for(int j=0;j<m;j++) {
                d2[i][j] = scanner.nextInt();
            }
        }
        deal(n,m,k,d1,d2);
    }

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
                br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
                while (st == null || !st.hasMoreElements()) {
                        try {
                                st = new StringTokenizer(br.readLine());
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
                }
                return st.nextToken();
        }

        int nextInt() {
                return Integer.parseInt(next());
        }

        long nextLong() {
                return Long.parseLong(next());
        }

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

        String nextLine(){
                String str = "";
    try {
            str = br.readLine();
    } catch (IOException e) {
            e.printStackTrace();
    }
    return str;
        }

    }
}


import java.util.*;
import java.io.*;
public class D {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }

    public static void sort(int arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(int arr[],int l1,int r1,int l2,int r2) {
        int tmp[]=new int[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }

    public static void sort(long arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(long arr[],int l1,int r1,int l2,int r2) {
        long tmp[]=new long[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }

    static int n,m,k,uu[][],rr[][],dd[][],ll[][],dp[][][];

    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        StringBuilder ans=new StringBuilder("");

        n=input.scanInt();
        m=input.scanInt();
        k=input.scanInt();

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

        uu=new int[n][m];
        rr=new int[n][m];
        dd=new int[n][m];
        ll=new int[n][m];

        for(int i=0;i<n;i++) {
            for(int j=0;j<m-1;j++) {
                int tmp=input.scanInt();
                rr[i][j]=tmp;
                ll[i][j+1]=tmp;
            }
        }

        for(int i=0;i<n-1;i++) {
            for(int j=0;j<m;j++) {
                int tmp=input.scanInt();
                dd[i][j]=tmp;
                uu[i+1][j]=tmp;
            }
        }

        for(int i=0;i<n;i++) {
            for(int j=0;j<m;j++) {
                if(k%2!=0) {
                    ans.append(-1+" ");
                    continue;
                }
                ans.append((2*solve(i,j,k/2))+" ");
            }
            ans.append("\n");
        }

        System.out.println(ans);
    }

    public static int solve(int x,int y,int rem) {
        if(rem==0) {
            return 0;
        }

        if(dp[x][y][rem]!=-1) {
            return dp[x][y][rem];
        }

        int ans=Integer.MAX_VALUE/10;
        if(uu[x][y]!=0) {
            ans=Math.min(ans,uu[x][y]+solve(x-1,y,rem-1));
        }
        if(rr[x][y]!=0) {
            ans=Math.min(ans,rr[x][y]+solve(x,y+1,rem-1));
        }
        if(dd[x][y]!=0) {
            ans=Math.min(ans,dd[x][y]+solve(x+1,y,rem-1));
        }
        if(ll[x][y]!=0) {
            ans=Math.min(ans,ll[x][y]+solve(x,y-1,rem-1));
        }

        dp[x][y][rem]=ans;

        return ans;
    }
}


import java.io.*;
import java.util.*;

public class CF1517D extends PrintWriter {
	CF1517D() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1517D o = new CF1517D(); o.main(); o.flush();
	}

	static final int INF = 0x3f3f3f3f;
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		if (k % 2 == 1) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					print("-1 ");
				println();
			}
			return;
		}
		k /= 2;
		int[][] hh = new int[n][m - 1];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m - 1; j++)
				hh[i][j] = sc.nextInt();
		int[][] vv = new int[n - 1][m];
		for (int i = 0; i < n - 1; i++)
			for (int j = 0; j < m; j++)
				vv[i][j] = sc.nextInt();
		int[][] dp = new int[n][m];
		int[][] dq = new int[n][m];
		while (k-- > 0) {
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++) {
					int x = INF;
					if (i > 0)
						x = Math.min(x, dp[i - 1][j] + vv[i - 1][j]);
					if (j > 0)
						x = Math.min(x, dp[i][j - 1] + hh[i][j - 1]);
					if (i + 1 < n)
						x = Math.min(x, dp[i + 1][j] + vv[i][j]);
					if (j + 1 < m)
						x = Math.min(x, dp[i][j + 1] + hh[i][j]);
					dq[i][j] = x;
				}
			int[][] tmp = dp; dp = dq; dq = tmp;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)
				print(dp[i][j] * 2 + " ");
			println();
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;
public class Main{
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        long[] nextArray(long n) {
            long[] a = new long[(int) n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
    static class FastWriter extends PrintWriter {
            FastWriter(){
                super(System.out);
            }
            void println(int[] array) {
                for(int i=0; i<array.length; i++) {
                    print(array[i]+" ");
                }
                println();
            }
            void println(long [] array) {
                for(int i=0; i<array.length; i++) {
                    print(array[i]+" ");
                }
                println();
            }
        }
    static int x,y;
    public static void main(String[] args){
        FastScanner in = new FastScanner();
        FastWriter out = new FastWriter();
        int n=in.nextInt();
        int m=in.nextInt();
        int k=in.nextInt();
        int[][] right=new int[n][m-1];
        int[][] down=new int[n-1][m];
        for (int i = 0; i < n; i++) {
            right[i]=in.nextArray(m-1);
        }
        for (int i = 0; i < n - 1; i++) {
            down[i]=in.nextArray(m);
        }
        if(k%2!=0){
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    out.print("-1 ");
                }
                out.println();
            }
        }else {
            int[][] dp=new int[n][m];
            int[][] dp1=new int[n][m];
            for (int i = 0; i < k / 2; i++) {
                for (int j = 0; j < n; j++) {
                    for (int l = 0; l < m; l++) {
                        int ans=Integer.MAX_VALUE;
                        if(j>0){
                            ans=Math.min(ans,dp[j-1][l]+down[j-1][l]);
                        }
                        if(l>0){
                            ans=Math.min(ans,dp[j][l-1]+right[j][l-1]);
                        }
                        if(j!=n-1){
                            ans=Math.min(ans,dp[j+1][l]+down[j][l]);
                        }
                        if(l!=m-1){
                            ans=Math.min(ans,dp[j][l+1]+right[j][l]);
                        }
                        dp1[j][l]=ans;
                    }
                }
                dp=dp1;
                dp1=new int[n][m];
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    out.println((2*dp[i][j])+" ");
                }
                out.println();
            }
        }
        out.close();
    }
}


import java.util.*;
import java.io.*;

public class D1517 {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int[][] costRight = new int[n][m - 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m - 1; j++) {
				costRight[i][j] = sc.nextInt();
			}
		}
		int[][] costDown = new int[n - 1][m];
		for (int i = 0; i < n - 1; i++) {
			for (int j = 0; j < m; j++) {
				costDown[i][j] = sc.nextInt();
			}
		}
		if (k % 2 == 1) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					pw.print(-1 + " ");
				}
				pw.println();
			}
			pw.close();
			return;
		}
		int[][][] dp = new int[k + 1][n][m];
		for (int w = 2; w <= k; w += 2) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					dp[w][i][j] = (int) 1e9;
					if (i + 1 < n)
						dp[w][i][j] = Math.min(dp[w][i][j], 2 * costDown[i][j] + dp[w - 2][i + 1][j]);
					if (i - 1 >= 0)
						dp[w][i][j] = Math.min(dp[w][i][j], 2 * costDown[i - 1][j] + dp[w - 2][i - 1][j]);
					if (j + 1 < m)
						dp[w][i][j] = Math.min(dp[w][i][j], 2 * costRight[i][j] + dp[w - 2][i][j + 1]);
					if (j - 1 >= 0)
						dp[w][i][j] = Math.min(dp[w][i][j], 2 * costRight[i][j - 1] + dp[w - 2][i][j - 1]);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				pw.print(dp[k][i][j] + " ");
			}
			pw.println();
		}
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader f) {
			br = new BufferedReader(f);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}


import java.util.*;

public class Main {
  public static Scanner scan = new Scanner(System.in);

  int n, m;
  int[][] x;
  int[][] y;
  int k, k2;

  int[][] sol0;
  int[][] sol1;

  public Main(int[][] x, int[][] y, int k) {
    this.x = x;
    this.y = y;
    this.k = k;
    this.n = x.length;
    this.m = x[0].length;
  }

  void go() {
    if(k%2 != 0) {
      for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
          System.out.print(-1 + " ");
        }
        System.out.println();
      }
      return;
    }
    k2 = k/2;
    sol0 = new int[n][m];
    sol1 = new int[n][m];

    for(int d=0; d<k2; ++d) {
      var zzz = sol1;
      sol1 = sol0;
      sol0 = zzz;

      for(int i=0; i<n; ++i)
        for(int j=0; j<m; ++j) {
          update(i,j);
        }
    }
    for(int i=0; i<n; ++i) {
      for(int j=0; j<m; ++j) {
        System.out.print(sol1[i][j]*2 + " ");
      }
      System.out.println();
    }

  }

  void update(int i, int j) {
    int ret = Integer.MAX_VALUE;
    if(i>0)
      ret = Math.min(ret, sol0[i-1][j] + y[i-1][j]);
    if(j>0)
      ret = Math.min(ret, sol0[i][j-1] + x[i][j-1]);
    if(i < n-1)
      ret = Math.min(ret, sol0[i+1][j] + y[i][j]);
    if(j < m-1)
      ret = Math.min(ret, sol0[i][j+1] + x[i][j]);
    sol1[i][j] = ret;
  }

  public static void main(String[] args) {
    int n = scan.nextInt();
    int m = scan.nextInt();
    int k = scan.nextInt();
    int x[][] = new int[n][m];
    int y[][] = new int[n][m];
    for(int i=0; i<n; ++i) {
      for(int j=0; j<m-1; ++j) {
        x[i][j] = scan.nextInt();
      }
    }
    for(int i=0; i<n-1; ++i) {
      for(int j=0; j<m; ++j) {
        y[i][j] = scan.nextInt();
      }
    }
    Main mm = new Main(x,y,k);
    mm.go();
  }

}


// Main Code at the Bottom
import java.util.*;
import java.io.*;
public class Main{
	//Fast IO class
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	//env=true;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    static long MOD=(long)1e9+7;
    //debug
    static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    static FastReader sc=new FastReader();
    static PrintWriter out=new PrintWriter(System.out);
    //Global variables and functions
    static int code(int x,int y) {
    	return 505*x+y;
    }
    static class pair{
    	int x,y;
    	pair(int a,int b){
    		this.x=a;
    		this.y=b;
    	}
    	public boolean equals(Object obj) {
    		if(obj == null || obj.getClass()!= this.getClass()) return false;
            pair p = (pair) obj;
            return (this.x==p.x && this.y==p.y);
        }
    	public int hashCode() {
            return Objects.hash(x,y);
        }
    }
    static int hor[][],ver[][];
    static int moves[][]= {{-1,0},{1,0},{0,-1},{0,1}};
    static int n,m;
    static int dp[][][];
    static int solve(int x,int y,int k) {
    	if(k==0) {
    		return 0;
    	}
    	if(dp[x][y][k]!=0) return dp[x][y][k];
    	int min=(int)MOD;
    	for(int mo[]: moves) {
			int X=x+mo[0],Y=y+mo[1];
			if(X<0 || X>=n || Y<0 || Y>=m) continue;
			int val=0;
			if(mo[0]==1) val=ver[x][y];
			else if(mo[0]==-1) val=ver[x-1][y];
			else if(mo[1]==1) val=hor[x][y];
			else val=hor[x][y-1];
			min=Math.min(min, 2*val+solve(X,Y,k-2));
		}
    	return dp[x][y][k]=min;
    }
    //Main function(The main code starts from here)
    public static void main (String[] args) throws java.lang.Exception {
    	int test=1;
    	//test=sc.nextInt();
    	while(test-->0) {
    		n=sc.nextInt();m=sc.nextInt();
    		int k=sc.nextInt();
    		if(k%2!=0) {
    			for(int i=0;i<n;i++) {
    				for(int j=0;j<m;j++) out.print(-1+" ");
    				out.println();
    			}
    			continue;
    		}
    		hor=new int[n][m-1];
    		ver=new int[n-1][m];
    		for(int i=0;i<n;i++) {
    			for(int j=0;j<m-1;j++) {
    				hor[i][j]=sc.nextInt();
    			}
    		}
    		for(int i=0;i<n-1;i++) {
    			for(int j=0;j<m;j++) {
    				ver[i][j]=sc.nextInt();
    			}
    		}
    		dp=new int[n][m][k+1];
    		for(int i=0;i<n;i++) {
    			for(int j=0;j<m;j++) {
    				out.print(solve(i,j,k)+" ");
    			}
    			out.println();
    		}

    	}
        out.flush();
        out.close();
    }
}