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

public class Main implements Runnable {
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        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 double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

        public String next() {
            return readString();
        }

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

    public static void main(String args[]) throws Exception {
        new Thread(null, new Main(), "Main", 1 << 27).start();
    }

    static class Pair {
        int f;
        int s;
        int p;
        PrintWriter w;

        // int t;

        Pair(int f, int s) {
            // Pair(int f,int s, PrintWriter w){
            this.f = f;
            this.s = s;
            // this.p = p;
            // this.w = w;
            // this.t = t;

        }

        public static Comparator<Pair> wc = new Comparator<Pair>() {
            public int compare(Pair e1,Pair e2){

            // 1 for swap
            if(Math.abs(e1.f)-Math.abs(e2.f)!=0){
            // e1.w.println("**"+e1.f+" "+e2.f);
                return -1*(Math.abs(e1.f)-Math.abs(e2.f));
            }
            else{
            // e1.w.println("##"+e1.f+" "+e2.f);
                return(Math.abs(e1.s)-Math.abs(e2.s));
            }

        }};
    }

    public Integer[] sort(Integer[] a) {
        Arrays.sort(a);
        return a;
    }

    public Long[] sort(Long[] a) {
        Arrays.sort(a);
        return a;
    }

    public static ArrayList<Integer> sieve(int N) {
        int i, j, flag;

        ArrayList<Integer> p = new ArrayList<Integer>();

        for (i = 1; i < N; i++) {

            if (i == 1 || i == 0)
                continue;

            flag = 1;

            for (j = 2; j <= i / 2; ++j) {
                if (i % j == 0) {
                    flag = 0;
                    break;
                }
            }
            if (flag == 1) {
                p.add(i);
            }
        }
        return p;
    }

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

    //// recursive dfs
    public static int dfs(int s, ArrayList<Integer>[] g, long[] dist, boolean[] v, PrintWriter w, int p) {
        v[s] = true;
        int ans = 1;
        // int n = dist.length - 1;
        int t = g[s].size();
        // int max = 1;
        for (int i = 0; i < t; i++) {
            int x = g[s].get(i);
            if (!v[x]) {
                // dist[x] = dist[s] + 1;
                ans = Math.min(ans, dfs(x, g, dist, v, w, s));
            } else if (x != p) {
                // w.println("* " + s + " " + x + " " + p);
                ans = 0;
            }
        }
        // max = Math.max(max,(n-p));
        return ans;
    }

    //// iterative BFS
    public static int bfs(int s, ArrayList<Integer>[] g, long[] dist, boolean[] b, PrintWriter w, int p) {
        b[s] = true;
        int siz = 1;
        // dist--;
        Queue<Integer> q = new LinkedList<>();
        q.add(s);
        while (q.size() != 0) {
            int i = q.poll();
            Iterator<Integer> it = g[i].listIterator();
            int z = 0;
            while (it.hasNext()) {
                z = it.next();
                if (!b[z]) {
                    b[z] = true;
                    // dist--;
                    dist[z] = dist[i] + 1;
                    // siz++;
                    q.add(z);
                } else if (z != p) {
                    siz = 0;
                }
            }

        }
        return siz;
    }

    public static int lower(int a[], int x) { // x is the target value or key
        int l = -1, r = a.length;
        while (l + 1 < r) {
            int m = (l + r) >>> 1;
            if (a[m] >= x)
                r = m;
            else
                l = m;
        }
        return r;
    }

    public static int upper(int a[], int x) {// x is the key or target value
        int l = -1, r = a.length;
        while (l + 1 < r) {
            int m = (l + r) >>> 1;
            if (a[m] <= x)
                l = m;
            else
                r = m;
        }
        return l + 1;
    }

    public static int lower(ArrayList<Integer> a, int x) { // x is the target value or key
        int l = -1, r = a.size();
        while (l + 1 < r) {
            int m = (l + r) >>> 1;
            if (a.get(m) >= x)
                r = m;
            else
                l = m;
        }
        return r;
    }

    public static int upper(ArrayList<Integer> a, int x) {// x is the key or target value
        int l = -1, r = a.size();
        while (l + 1 < r) {
            int m = (l + r) >>> 1;
            if (a.get(m) <= x)
                l = m;
            else
                r = m;
        }
        return l + 1;
    }

    public static long power(long x, long y, long m) {
        if (y == 0)
            return 1;

        long p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        if (y % 2 == 0)
            return p;
        else
            return (x * p) % m;
    }
    public void yesOrNo(boolean f){
        if(f){
            w.println("YES");
        }
        else{
            w.println("NO");
        }
    }

    //////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////
    // code here
    int oo = (int) 1e9;
    int[] parent;
    int[] dist;
    int[] height;
    boolean[] vis;
    // ArrayList<Integer>[] g;
    //int[] col;
    //HashMap<Long, Boolean>[] dp;
    char[][] g;
    // boolean[][] v;
    //long[] a;
    // ArrayList<Integer[]> a;
    // int[][] ans;
    long[][][] dp;
    long mod;
    int n;
    int m;
    int k;
    long[][] pre;
    // StringBuilder[] a;
    // StringBuilder[] b;
    //StringBuilder ans;
    int[][] col;
    int[][] row;
    PrintWriter w = new PrintWriter(System.out);

    public void run() {

        InputReader sc = new InputReader(System.in);

        int defaultValue = 0;
        mod = 1000000007;

        int test = 1;
        //test = sc.nextInt();
        while (test-- > 0) {
            n = sc.nextInt();
            m = sc.nextInt();
            k = sc.nextInt();

            col = new int[n][m-1];
            row = new int[n-1][m];

            dp = new long[n][m][21];
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    Arrays.fill(dp[i][j],oo);
                }
            }

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

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

            if(k%2!=0){
                for(int i=0;i<n;i++){
                    for(int j=0;j<m;j++){
                        w.print(-1+" ");
                    }
                    w.println("");
                }
            }
            else{
                for(int i=0;i<n;i++){
                    for(int j=0;j<m;j++){
                        long ans = sol(i,j,k/2);
                        w.print((ans*2)+" ");
                    }
                    w.println("");
                }

            }

        }

        w.flush();
        w.close();

    }

    public long sol(int i, int j, int steps){
        if(steps == 0)return 0;
        else if(dp[i][j][steps]!=oo)return dp[i][j][steps];
        else{
            long ans = oo;
            if(i-1>-1){
                ans = Math.min(ans,sol(i-1,j,steps-1)+row[i-1][j]);
            }
            if(i+1<n){
                ans = Math.min(ans,sol(i+1,j,steps-1)+row[i][j]);
            }
            if(j-1>-1){
                ans = Math.min(ans,sol(i,j-1,steps-1)+col[i][j-1]);
            }
            if(j+1<m){
                ans = Math.min(ans,sol(i,j+1,steps-1)+col[i][j]);
            }
            dp[i][j][steps] = Math.min(dp[i][j][steps],ans);
            return dp[i][j][steps];
        }
    }

}


import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    static int[][] l,r,u,d;
    static int[][][]dist;
    static int inf=Integer.MAX_VALUE;
    static class Node{
        int x,y,len,dis;
        Node(int x,int y,int len,int dis){
            this.x=x;this.y=y;this.len=len;this.dis=dis;
        }
    }
    public static void process()throws IOException
    {
        int n=ni();
        int m=ni();
        int k=ni();
        dist=new int[n][m][k/2+1];
        l=new int[n][m];
        r=new int[n][m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m-1;j++)
                l[i][j]=r[i][j+1]=ni();
        u=new int[n][m];
        d=new int[n][m];
        for(int i=0;i<n-1;i++)
            for(int j=0;j<m;j++)
                d[i][j]=u[i+1][j]=ni();
        if(k%2==1)
        {
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                    p("-1 ");
                pn("");
            }
            return;
        }
        k/=2;
        for(int kk=1;kk<=k;kk++)
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                dist[i][j][kk]=inf;
                if(i!=0)
                    dist[i][j][kk]=Math.min(dist[i][j][kk],dist[i-1][j][kk-1]+u[i][j]);
                if(i!=n-1)
                    dist[i][j][kk]=Math.min(dist[i][j][kk],dist[i+1][j][kk-1]+d[i][j]);
                if(j!=0)
                    dist[i][j][kk]=Math.min(dist[i][j][kk],dist[i][j-1][kk-1]+r[i][j]);
                if(j!=m-1)
                    dist[i][j][kk]=Math.min(dist[i][j][kk],dist[i][j+1][kk-1]+l[i][j]);
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
                p(2*dist[i][j][k]+" ");
            pn("");
        }

    }
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
       // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}


import java.util.*;
import java.io.*;
public class D {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int[][] lr = new int[n][m-1];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m-1; j++){
				lr[i][j] = sc.nextInt();
			}
		}
		int[][] ud = new int[n-1][m];
		for(int i = 0; i < n-1; i++){
			for(int j = 0; j < m; j++){
				ud[i][j] = sc.nextInt();
			}
		}
		if(k % 2 == 1) {
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					sb.append(-1+" ");
				}
				sb.replace(sb.length()-1, sb.length(), "\n");
			}
			PrintWriter pw = new PrintWriter(System.out);
			pw.println(sb.toString().trim());
			pw.flush();
		}
		else {
			int[][] dir = {{0,1},{0,-1},{1,0},{-1,0}};
			long[][][] dp = new long[k/2+1][n][m];
			for(int s = 1; s <= k/2; s++) {
				for(int i = 0; i < n; i++){
					for(int j = 0; j < m; j++){
						dp[s][i][j] = Long.MAX_VALUE;
						for(int[] d: dir) {
							int u = i + d[0], v = j + d[1];
							if(u >= 0 && u < n && v >= 0 && v < m) {
								long w = calc(i, j, u, v, lr, ud);
								dp[s][i][j] = Math.min(dp[s][i][j], dp[s-1][u][v] + 2*w);
							}
						}
					}
				}
			}
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++){
					sb.append(dp[k/2][i][j]+" ");
				}
				sb.replace(sb.length()-1, sb.length(), "\n");
			}
			PrintWriter pw = new PrintWriter(System.out);
			pw.println(sb.toString().trim());
			pw.flush();
		}
	}
	static long calc(int i, int j, int u, int v, int[][] lr, int[][] ud) {
		if(i == u) {
			return lr[i][Math.min(j, v)];
		}
		else {
			return ud[Math.min(i, u)][j];
		}
	}

	static class Pair implements Comparable<Pair>{
		int x, y;
		public Pair(int x, int y) {
			this.x = x; this.y = y;
		}
		@Override
		public int compareTo(Pair p) {
			if(x == p.x) return y - p.y;
			else return x - p.x;
		}
		public String toString() {
			return x+" "+y;
		}
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
}


import java.util.*;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Scanner;
public class D{

    static void sort(int[] A){

        int n = A.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = A[i];
            int randomPos = i + rnd.nextInt(n-i);
            A[i] = A[randomPos];
            A[randomPos] = tmp;
        }
        Arrays.sort(A);
    }

    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        //int cases = sc.nextInt();

        //for(int i=0;i<cases;i++)
        {
            int n = sc.nextInt();
            int m=sc.nextInt();
            int steps=sc.nextInt();
            long arr[][][] = new long[n][m][5];
            for(int j=0;j<n;j++)
            {
                for(int k=0;k<m-1;k++)
                {
                    long num=sc.nextLong();
                    arr[j][k][1]=num;
                    arr[j][k+1][3]=num;
                }
            }

            for(int j=0;j<n-1;j++)
            {
                for(int k=0;k<m;k++)
                {
                    long num=sc.nextLong();
                    arr[j][k][2]=num;
                    arr[j+1][k][4]=num;
                }
            }

            long temp[][]=new long[n][m];
            long ans[][]=new long[n][m];
            for(int i=0;i<steps/2;i++)
            {
                for(int j=0;j<n;j++)
                {
                    for(int k=0;k<m;k++)
                    {
                        long min=Long.MAX_VALUE;
                        if(k>0)
                        {
                            long f=arr[j][k][3]+ans[j][k-1];
                            min=Math.min(min,f);
                        }

                        if(k<m-1)
                        {
                            long f=arr[j][k][1]+ans[j][k+1];
                            min=Math.min(min,f);
                        }

                        if(j>0)
                        {
                            long f=arr[j][k][4]+ans[j-1][k];
                            min=Math.min(min,f);
                        }

                        if(j<n-1)
                        {
                            long f=arr[j][k][2]+ans[j+1][k];
                            min=Math.min(min,f);
                        }

                        temp[j][k]=min;
                    }
                }

                for(int j=0;j<n;j++)
                {
                    for(int k=0;k<m;k++)
                    {
                        ans[j][k]=temp[j][k];
                    }
                }
            }

            StringBuilder p=new StringBuilder();
            for(int j=0;j<n;j++)
            {
                for(int k=0;k<m;k++)
                {
                    if(steps%2!=0)
                    {
                        p.append(-1+" ");
                    }
                    else
                    {
                    p.append(2*ans[j][k]+" ");}
                }

                p.append("\n");
            }

            System.out.println(p);
        }

    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;
import java.util.function.Predicate;

public class Main{
    public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
    static long MOD = (long) (1e9 + 7);
    //    static long MOD = 998244353;
    static long MOD2 = MOD * MOD;
    static FastReader sc = new FastReader();
    static int pInf = Integer.MAX_VALUE;
    static int nInf = Integer.MIN_VALUE;
    static long ded = (long)(1e17)+9;
    public static void main(String[] args) throws Exception {
        int test = 1;
//        test = sc.nextInt();
        for (int i = 1; i <= test; i++){
//            out.print("Case #"+i+": ");
            solve();
        }
        out.flush();
        out.close();
    }
    static int n,m;
    static int[][] hor,ver;
    static Long[][][] dp;
    static void solve(){
        n = sc.nextInt();
        m = sc.nextInt();
        int k = sc.nextInt();
        dp = new Long[n+1][m+1][k+1];
        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();
            }
        }
        if(k%2==1){
            for(int i = 0; i < n; i++){
                for(int j = 0; j < m; j++){
                    out.print(-1+" ");
                }
                out.println();
            }
            return;
        }
        k = k/2;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                long[] dp = new long[k+1];
                for(int l = 1; l <= k; l++){
                    dp[l] = cal(i,j,l);
                }
                for(int l = 1; l <= k; l++){
                    for(int g = 1; g < l; g++){
                        dp[l] = Math.min(dp[l],dp[g]+dp[l-g]);
                    }
                }
                out.print(2*dp[k]+" ");
            }
            out.println();
        }
    }
    static long cal(int i, int j,int k){
        if(k==0)return 0;
        if(dp[i][j][k]!=null)return dp[i][j][k];
        long ans = ded;
        for(int h = 0; h < 4; h++){
            int ni = i+di[h];
            int nj = j+dj[h];
            if(e(ni,nj)){
                int cost = 0;
                if(ni==i){
                    if(nj>j){
                        cost = hor[i][j];
                    }else{
                        cost = hor[i][nj];
                    }
                }if(nj==j){
                    if(ni>i){
                        cost = ver[i][j];
                    }else{
                        cost = ver[ni][j];
                    }
                }
                ans = Math.min(ans,(cost)+cal(ni,nj,k-1));
            }
        }
        return dp[i][j][k] =  ans;
    }
    static int[] di = new int[]{0,-1,0,1};
    static int[] dj = new int[]{-1,0,1,0};
    static boolean e(int i, int j){
        return i>=0&&j>=0&&i<n&&j<m;
    }
    static class Pair implements Comparable<Pair> {
        int x;
        int y;
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
        @Override
        public int compareTo(Pair o){
            return this.x-o.x;
        }

        @Override
        public String toString() {
            return "Pair{" + "x=" + x + ", y=" + y + '}';
        }

        public boolean equals(Pair o){
            return this.x==o.x&&this.y==o.y;
        }
    }
    public static long mul(long a, long b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }
    public static long add(long a, long b) {
        return ((a % MOD) + (b % MOD)) % MOD;
    }
    public static long c2(long n) {
        if ((n & 1) == 0) {
            return mul(n / 2, n - 1);
        } else {
            return mul(n, (n - 1) / 2);
        }
    }
    //Shuffle Sort
    static final Random random = new Random();
    static void ruffleSort(int[] a) {
        int n = a.length;//shuffle, then sort
        for (int i = 0; i < n; i++) {
            int oi = random.nextInt(n); int temp= a[oi];
            a[oi] = a[i];
            a[i] = temp;
        }
        Arrays.sort(a);
    }
    //Brian Kernighans Algorithm
    static long countSetBits(long n) {
        if (n == 0) return 0;
        return 1 + countSetBits(n & (n - 1));
    }
    //Euclidean Algorithm
    static long gcd(long A, long B) {
        if (B == 0) return A;
        return gcd(B, A % B);
    }
    //Modular Exponentiation
    static long fastExpo(long x, long n) {
        if (n == 0) return 1;
        if ((n & 1) == 0) return fastExpo((x * x) % MOD, n / 2) % MOD;
        return ((x % MOD) * fastExpo((x * x) % MOD, (n - 1) / 2)) % MOD;
    }
    //AKS Algorithm
    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 <= Math.sqrt(n); i += 6)
            if (n % i == 0 || n % (i + 2) == 0) return false;
        return true;
    }
    public static long modinv(long x) {
        return modpow(x, MOD - 2);
    }
    public static long modpow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        long x = modpow(a, b / 2);
        x = (x * x) % MOD;
        if (b % 2 == 1) {
            return (x * a) % MOD;
        }
        return x;
    }

    static 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;
        }
    }
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.ObjectInputStream.GetField;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.sound.sampled.ReverbType;

public class N718 {
	static PrintWriter out;
	static Scanner sc;
	static ArrayList<int[]>q,w,x;
	static ArrayList<Integer>adj[];
	static HashSet<Integer>primesH;
	static boolean prime[];
	//static ArrayList<Integer>a;
	static HashSet<Long>tmp;
	static int[][][]dist;
	static boolean[]v;
	static int[]a,b,c,d;
	static Boolean[][]dp;
	static char[][]mp;
	static int A,B,n,m,h,ans,sum;
	//static String a,b;
	static long oo=(long)1e9+7;
	public static void main(String[]args) throws IOException {
		sc=new Scanner(System.in);
		out=new PrintWriter(System.out);
		//A();
		//B();
		//C();
		D();
		//E();
		//F();
		//G();
		out.close();
	}
	  private static void A() throws IOException {
		  int t=ni();
		  while(t-->0) {
				long l=nl();
				if(l%2050!=0)ol(-1);
				else {
					long num=l/2050;
					int cnt=0;
					while(num>0) {
						cnt+=num%10;
						num/=10;
					}
					ol(cnt);

				}
		  }

	   }
		static void B() throws IOException {
			int t=ni();
			while(t-->0) {
				int n=ni(),m=ni();
				int[][]a=nmi(n,m);
				PriorityQueue<int[]>pq=new PriorityQueue<int[]>((u,v)->u[0]-v[0]);
				ArrayList<Integer>[]nums=new ArrayList[n];
				for(int i=0;i<n;i++) {
					//nums[i]=new ArrayList<Integer>();
					for(int j=0;j<m;j++) {
						///nums[i].add(a[i][j]);
						pq.add(new int[] {a[i][j],i});
					}
				}
				int[][]ans=new int[n][m];
				for(int i=0;i<m;i++) {
					int[]x=pq.poll();
					ans[x[1]][i]=x[0];
				}
				int []indices=new int[n];
				while(!pq.isEmpty()) {
					int[]x=pq.poll();
					int i=x[1];
					while(ans[i][indices[i]]!=0) {
						indices[i]++;
					}
					ans[i][indices[i]]=x[0];
				}
				for(int i=0;i<n;i++) {
					for(int j=0;j<m;j++) {
						out.print(ans[i][j]+" ");
					}
					ol("");
				}
			}
		}

		static void C() throws IOException{
			 int t=1;
			 while(t-->0) {
				 int n=ni();
				 a=nai(n);
				 int[][]ans=new int[n][n];
				 for(int i=0;i<n;i++)ans[i][i]=a[i];
				 for(int i=n-1;i>=0;i--) {
					 int j=i,k=i;
					 int cur=ans[i][i];
					 cur--;
					 while(cur>0) {
						 j++;
						 if(j>=n||ans[j][k]!=0) {
							 j--;
							 k--;
						 }
						 ans[j][k]=ans[i][i];
						 cur--;
					 }
				 }
				 for(int i=0;i<n;i++) {
					 for(int j=0;j<=i;j++) {
						 out.print(ans[i][j]+" ");
					 }
					 ol("");
				 }
			 }
		}
		private static Boolean dp(int i, int j) {
			if(j>sum/2)return false;
			if(i==x.size()) {
				return sum/2==j;
			}
			if(dp[i][j]!=null)return dp[i][j];

			return dp[i][j]=dp(i+1,j+x.get(i)[0])||dp(i+1,j);
		}
		static boolean isPrime(long n) {
			if(n==2)return true;
			if(n<2||n%2==0)return false;

			for(long i=3L;i*i<n;i+=2l) {
				long rem=(n%i);
				if(rem==0)return false;
			}
			return true;
		}
		static void D() throws IOException {
			int t=1;
			while(t-->0) {
				int n=ni(),m=ni(),k=ni();
				int[][]ans=new int[n][m];
				dist=new int[n][m][4];
				for(int i=0;i<n;i++)for(int j=0;j>m;j++)
					Arrays.fill(dist[i][j], Integer.MAX_VALUE);
				int x;
				for(int i=0;i<n;i++) {
					for(int j=0;j<m-1;j++) {
						dist[i][j][2]=(x=ni());
						dist[i][j+1][3]=x;
					}
				}
				for(int i=0;i<n-1;i++) {
					for(int j=0;j<m;j++) {
						dist[i][j][1]=(x=ni());
						dist[i+1][j][0]=x;
					}
				}
				int[][]nans=new int[n][m];
				if(k%2==1) {
					for(int i=0;i<n;i++)Arrays.fill(ans[i], -1);
				}else {
					for(int ii=0;ii<k/2;ii++) {
					for(int i=0;i<n;i++) {

						for(int j=0;j<m;j++) {
							nans[i][j]=Integer.MAX_VALUE;
							if(i>0)
								nans[i][j]=Math.min(nans[i][j], ans[i-1][j]+2*dist[i-1][j][1]);
							if(i<n-1)
								nans[i][j]=Math.min(nans[i][j], ans[i+1][j]+2*dist[i+1][j][0]);
							if(j>0)
								nans[i][j]=Math.min(nans[i][j], ans[i][j-1]+2*dist[i][j-1][2]);
							if(j<m-1)
								nans[i][j]=Math.min(nans[i][j], ans[i][j+1]+2*dist[i][j+1][3]);
						}
					}
					int[][]tmp=ans;
					ans=nans;
					nans=tmp;
					}
				}
				for(int i=0;i<n;i++) {
					for(int j=0;j<m;j++) {
						out.print(ans[i][j]+" ");
					}
					ol("");
				}
			}
		}
		private static int bfs(int i, int j,int k) {
			boolean [][]vis=new boolean[dist.length][dist[0].length];
			Queue<int[]>q=new LinkedList<int[]>();
			int mn=Integer.MAX_VALUE;
			q.add(new int[] {i,j,0,0});
			int[]dx=new int[] {-1,1,0,0};
			int[]dy=new int[] {0,0,1,-1};
			while(!q.isEmpty()) {
				int []x=q.poll();
				vis[x[0]][x[1]]=true;
				int c=x[2];
				if(c>k/2)continue;
				if(c>0&&k%c==0&&(k/c)%2==0) {
					mn=Math.min(mn,x[3]*k/c );
				}
				for(int a=0;a<4;a++) {
					int nx=x[0]+dx[a];
					int ny=x[1]+dy[a];
					if(valid(nx,ny)&&!vis[nx][ny]) {
						q.add(new int[] {nx,ny,c+1,x[3]+dist[x[0]][x[1]][a]});
					}
				}

			}
			return mn;
		}
		private static boolean valid(int nx, int ny) {
			return nx>=0&&nx<dist.length&&ny>=0&&ny<dist[0].length;
		}
		static int gcd (int a, int b) {
		    return b==0?a:gcd (b, a % b);
		}

	static void E() throws IOException {
		int t=ni();
		while(t-->0) {

		}

	}

	static void F() throws IOException {
		int t=ni();
		while(t-->0) {

		}
	}
	static void CC() throws IOException {
		for(int kk=2;kk<21;kk++) {
			ol(kk+"   -------");
		int n=kk;
		int k=n-2;
		int msk=1<<k;
		int[]a=new int[k];
		for(int i=0;i<a.length;i++)a[i]=i+2;
		int mx=1;
		int ms=0;
		for(int i=1;i<msk;i++) {
			long prod=1;
			int cnt=0;
			for(int j=0;j<a.length;j++) {
				if(((i>>j)&1)!=0) {
					prod*=a[j];
					cnt++;
				}
			}
			if(cnt>=mx&&prod%n==1) {
				mx=cnt;
				ms=i;
			}

		}
		ol(mx==1?mx:mx+1);
		out.print(1+" ");
		long pr=1;
		for(int j=0;j<a.length;j++) {
			if(((ms>>j)&1)!=0) {
				out.print(a[j]+" ");
				pr*=a[j];
			}
		}
		ol("");
		ol("Prod: "+pr);
		ol(n+"*"+((pr-1)/n)+" + "+1);
		}
	}
	static int ni() throws IOException {
		return sc.nextInt();
	}
	static double nd() throws IOException {
		return sc.nextDouble();
	}
	static long nl() throws IOException {
		return  sc.nextLong();
	}
	static String ns() throws IOException {
		return sc.next();
	}
	static int[] nai(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		return a;
	}
	static long[] nal(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		return a;
	}
	static int[][] nmi(int n,int m) throws IOException{
		int[][]a=new int[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextInt();
			}
		}
		return a;
	}

	static long[][] nml(int n,int m) throws IOException{
		long[][]a=new long[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextLong();
			}
		}
		return a;
	}
	static void o(String x) {
		out.print(x);
	}
	static void ol(String x) {
		out.println(x);
	}
	static void ol(int x) {
		out.println(x);
	}
	static void disp1(int []a) {
		for(int i=0;i<a.length;i++) {
			out.print(a[i]+" ");
		}
		out.println();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;

public class P1517D {
	// author: Nagabhushan S Baddi

	// PRIMARY VARIABLES
	private static int n, m, k;
	private static int[][] hor, ver, a, b;
	private static long ans;
	private static int[][] id;
	private static Integer[][][] dp;
	private static int idf;
	private static String s, t;
	private static HashMap<Integer, ArrayList<Integer>> g;

	// CONSTANTS
	private static final int MOD = (int) 1e9 + 7;

	public static void main(String[] args) {
		n = ini();
		m = ini();
		k = ini();

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

		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] = ini();
			}
		}
		for(int i=0; i<n-1; i++) {
			for(int j=0; j<m; j++) {
				ver[i][j] = ini();
			}
		}

		dp = new Integer[n][m][k+1];

		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				print(2*solve(i, j, k/2)+" ");
			}
			println();
		}

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

	}

	private static int solve(int i, int j, int kLeft) {
		if (i<0 || i>=n || j<0 || j>=m) {
			return (int)1e9;
		} else if (kLeft==0) {
			return 0;
		}

		if (dp[i][j][kLeft]!=null) {
			return dp[i][j][kLeft];
		}

		int ans = (int)1e9;

		final int[] dx = {-1, 1, 0, 0};
		final int[] dy = {0, 0, -1, 1};

		for(int type=0; type<4; type++) {
			int ni = i+dx[type];
			int nj = j+dy[type];
			if (ni<0 || ni>=n || nj<0 || nj>=m) continue;

			int inhibit = 0;
			if (type==0) {
				inhibit = ver[ni][nj];
			} else if (type==1) {
				inhibit = ver[i][j];
			} else if (type==2) {
				inhibit = hor[ni][nj];
			} else {
				inhibit = hor[i][j];
			}

			ans = Math.min(ans, inhibit+solve(ni, nj, kLeft-1));
		}

		return dp[i][j][kLeft]=ans;
	}

	// INIT
	private static void initCase(int z) {
		idf = z;
		ans = 0;
	}

	// PRINT ANSWER
	private static void printAns(Object o) {
		out.println(o);
	}

	private static void printAns(Object o, int testCaseNo) {
		out.println("Case #" + testCaseNo + ": " + o);
	}

	private static void printArray(Object[] a) {
		for (int i = 0; i < a.length; i++) {
			out.print(a[i] + " ");
		}
		out.println();
	}

	// SORT SHORTCUTS - QUICK SORT TO MERGE SORT
	private static void sort(int[] a) {
		int n = a.length;
		Integer[] b = new Integer[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	private static void sort(long[] a) {
		int n = a.length;
		Long[] b = new Long[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	// INPUT SHORTCUTS

	private static int[] ina(int n) {
		int[] temp = new int[n];
		for (int i = 0; i < n; i++) {
			temp[i] = in.nextInt();
		}
		return temp;
	}

	private static int[][] ina2d(int n, int m) {
		int[][] temp = new int[n][m];
		for (int i = 0; i < n; i++) {
			temp[i] = ina(m);
		}
		return temp;
	}

	private static int ini() {
		return in.nextInt();
	}

	private static long inl() {
		return in.nextLong();
	}

	private static double ind() {
		return Double.parseDouble(ins());
	}

	private static String ins() {
		return in.readString();
	}

	// PRINT SHORTCUTS
	private static void println(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.write("\n");
	}

	private static void pd(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.flush();
		out.write("\n");
	}

	private static void print(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
	}

	// GRAPH SHORTCUTS
	private static HashMap<Integer, ArrayList<Integer>> intree(int n) {

		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();
		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;
	}

	private static HashMap<Integer, ArrayList<Integer>> ingraph(int n, int m) {
		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;

	}

	private static HashMap<Integer, ArrayList<Integer>> indirectedgraph(int n, int m) {
		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
		}

		return g;

	}

	private static HashMap<Integer, ArrayList<Edge>> inweightedgraph(int n, int m) {
		HashMap<Integer, ArrayList<Edge>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			int w = ini();
			Edge edge = new Edge(u, v, w);
			g.get(u).add(edge);
			g.get(v).add(edge);
		}

		return g;

	}

	private static class Edge implements Comparable<Edge> {
		private int u, v;
		private long w;

		public Edge(int a, int b, long c) {
			u = a;
			v = b;
			w = c;
		}

		public int other(int x) {
			return (x == u ? v : u);
		}

		public int compareTo(Edge edge) {
			return Long.compare(w, edge.w);
		}
	}

	private static class Pair {
		private int u, v;

		public Pair(int a, int b) {
			u = a;
			v = b;
		}

		public int hashCode() {
			return u + v + u * v;
		}

		public boolean equals(Object object) {
			Pair pair = (Pair) object;
			return u == pair.u && v == pair.v;
		}
	}

	private static class Node implements Comparable<Node> {
		private int u;
		private long dist;

		public Node(int a, long b) {
			u = a;
			dist = b;
		}

		public int compareTo(Node node) {
			return Long.compare(dist, node.dist);
		}
	}

	// MATHS AND NUMBER THEORY SHORTCUTS
	private static int gcd(int a, int b) {
		// O(log(min(a,b)))
		if (b == 0)
			return a;

		return gcd(b, a % b);
	}

	private static long modExp(long a, long b) {
		if (b == 0)
			return 1;

		a %= MOD;

		long exp = modExp(a, b / 2);

		if (b % 2 == 0) {
			return (exp * exp) % MOD;
		} else {
			return (a * ((exp * exp) % MOD)) % MOD;
		}
	}

	private long mul(int a, int b) {
		return a * 1L * b;
	}

	// Segment Tree
	private static class SegmentTree<T extends Comparable<T>> {
		private int n, m;
		private T[] a;
		private T[] seg;
		private T NULLVALUE;

		public SegmentTree(int n, T NULLVALUE) {
			this.NULLVALUE = NULLVALUE;
			this.n = n;
			m = 4 * n;
			seg = (T[]) new Object[m];

		}

		public SegmentTree(T[] a, int n, T NULLVALUE) {
			this.NULLVALUE = NULLVALUE;
			this.a = a;
			this.n = n;
			m = 4 * n;
			seg = (T[]) new Object[m];
			construct(0, n - 1, 0);
		}

		private void update(int pos) {
			// Range Sum
			// seg[pos] = seg[2*pos+1]+seg[2*pos+2];

			// Range Min
			if (seg[2 * pos + 1].compareTo(seg[2 * pos + 2]) <= 0) {
				seg[pos] = seg[2 * pos + 1];
			} else {
				seg[pos] = seg[2 * pos + 2];
			}
		}

		private T optimum(T leftValue, T rightValue) {
			// Range Sum
			// return leftValue+rightValue;

			// Range Min
			if (leftValue.compareTo(rightValue) <= 0) {
				return leftValue;
			} else {
				return rightValue;
			}
		}

		public void construct(int low, int high, int pos) {
			if (low == high) {
				seg[pos] = a[low];
				return;
			}

			int mid = (low + high) / 2;

			construct(low, mid, 2 * pos + 1);
			construct(mid + 1, high, 2 * pos + 2);
			update(pos);
		}

		public void add(int index, T value) {
			add(index, value, 0, n - 1, 0);
		}

		private void add(int index, T value, int low, int high, int pos) {
			if (low == high) {
				seg[pos] = value;
				return;
			}

			int mid = (low + high) / 2;

			if (index <= mid) {
				add(index, value, low, mid, 2 * pos + 1);
			} else {
				add(index, value, mid + 1, high, 2 * pos + 2);
			}
			update(pos);
		}

		public T get(int qlow, int qhigh) {
			return get(qlow, qhigh, 0, n - 1, 0);
		}

		public T get(int qlow, int qhigh, int low, int high, int pos) {
			if (qlow > low || low > qhigh) {
				return NULLVALUE;
			} else if (qlow <= low || qhigh >= high) {
				return seg[pos];
			} else {
				int mid = (low + high) / 2;
				T leftValue = get(qlow, qhigh, low, mid, 2 * pos + 1);
				T rightValue = get(qlow, qhigh, mid + 1, high, 2 * pos + 2);

				return optimum(leftValue, rightValue);
			}
		}
	}

	// DSU
	private static class DSU {
		private int[] id;
		private int[] size;
		private int n;

		public DSU(int n) {
			this.n = n;

			id = new int[n];
			for (int i = 0; i < n; i++) {
				id[i] = i;
			}

			size = new int[n];
			Arrays.fill(size, 1);
		}

		private int root(int u) {
			while (u != id[u]) {
				id[u] = id[id[u]];
				u = id[u];
			}
			return u;
		}

		public boolean connected(int u, int v) {
			return root(u) == root(v);
		}

		public void union(int u, int v) {
			int p = root(u);
			int q = root(v);

			if (size[p] >= size[q]) {
				id[q] = p;
				size[p] += size[q];
			} else {
				id[p] = q;
				size[q] += size[p];
			}
		}
	}

	// KMP
	private static int countSearch(String s, String p) {
		int n = s.length();
		int m = p.length();

		int[] b = backTable(p);

		int j = 0;
		int count = 0;

		for (int i = 0; i < n; i++) {
			if (j == m) {
				j = b[j - 1];
				count++;
			}
			while (j != 0 && s.charAt(i) != p.charAt(j)) {
				j = b[j - 1];
			}
			if (s.charAt(i) == p.charAt(j)) {
				j++;
			}
		}

		if (j == m)
			count++;

		return count;
	}

	private static int[] backTable(String p) {
		int m = p.length();

		int j = 0;
		int[] b = new int[m];

		for (int i = 1; i < m; i++) {
			while (j != 0 && p.charAt(i) != p.charAt(j)) {
				j = b[j - 1];
			}
			if (p.charAt(i) == p.charAt(j)) {
				b[i] = ++j;
			}
		}
		return b;
	}

	private static class LCA {
		private HashMap<Integer, ArrayList<Integer>> g;
		private int[] level;
		private int[] a;
		private int[][] P;
		private int n, m;
		private int[] xor;

		public LCA(HashMap<Integer, ArrayList<Integer>> g, int[] a) {
			this.g = g;
			this.a = a;
			n = g.size();
			m = (int) (Math.log(n) / Math.log(2)) + 5;
			P = new int[n][m];
			xor = new int[n];
			level = new int[n];

			preprocess();
		}

		private void preprocess() {
			dfs(0, -1);

			for (int j = 1; j < m; j++) {
				for (int i = 0; i < n; i++) {
					if (P[i][j - 1] != -1) {
						P[i][j] = P[P[i][j - 1]][j - 1];
					}
				}
			}
		}

		private void dfs(int u, int p) {
			P[u][0] = p;
			xor[u] = a[u] ^ (p == -1 ? 0 : xor[p]);
			level[u] = (p == -1 ? 0 : level[p] + 1);

			for (int v : g.get(u)) {
				if (v == p)
					continue;
				dfs(v, u);
			}
		}

		public int lca(int u, int v) {
			if (level[v] > level[u]) {
				int temp = v;
				v = u;
				u = temp;
			}

			for (int j = m; j >= 0; j--) {
				if (level[u] - (1 << j) < level[v]) {
					continue;
				} else {
					u = P[u][j];
				}
			}

			if (u == v)
				return u;

			for (int j = m - 1; j >= 0; j--) {
				if (P[u][j] == -1 || P[u][j] == P[v][j]) {
					continue;
				} else {
					u = P[u][j];
					v = P[v][j];
				}
			}

			return P[u][0];
		}

		private int xor(int u, int v) {
			int l = lca(u, v);

			return xor[u] ^ xor[v] ^ a[l];
		}
	}

	// FAST INPUT OUTPUT LIBRARY
	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);

	private static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

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

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 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 {
				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 {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

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

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

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

	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskD {
        Scanner in;
        PrintWriter out;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            this.in = in;
            this.out = out;
            run();
        }

        void run() {
            int n = in.nextInt();
            int m = in.nextInt();
            int k = in.nextInt();
            int[][][] dis = new int[n][m][4];
            int[][] dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
            int tmp;
            final int M = (int) (1e8);
            Algo.fill(dis, M);
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m - 1; j++) {
                    tmp = in.nextInt();
                    dis[i][j][0] = tmp;
                    dis[i][j + 1][1] = tmp;
                }
            }
            for (int i = 0; i < n - 1; i++) {
                for (int j = 0; j < m; j++) {
                    tmp = in.nextInt();
                    dis[i][j][2] = tmp;
                    dis[i + 1][j][3] = tmp;
                }
            }
            int[][] ans = new int[n][m];

            if (k % 2 == 1) {
                Algo.fill(ans, -1);
            } else {
                int halfK = k / 2;
                int[][][] dp = new int[halfK + 1][n][m];
                Algo.fill(dp, M);

                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        dp[0][i][j] = 0;
                    }
                }

                for (int step = 1; step <= halfK; step++) {
                    for (int i = 0; i < n; i++) {
                        for (int j = 0; j < m; j++) {
                            for (int d = 0; d < dir.length; d++) {
                                int toX = i + dir[d][0];
                                int toY = j + dir[d][1];
                                if (toX < 0 || toY < 0 || toX >= n || toY >= m) continue;
                                dp[step][i][j] = Math.min(dp[step - 1][toX][toY] + 2 * dis[i][j][d], dp[step][i][j]);
                            }
                        }
                    }
                }
                ans = dp[halfK];
            }

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

        }

    }

    static class Algo {
        public static void fill(int[][] iss, int v) {
            for (int[] is : iss) Arrays.fill(is, v);
        }

        public static void fill(int[][][] isss, int v) {
            for (int[][] iss : isss) Algo.fill(iss, v);
        }

    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            eat("");
        }

        private void eat(String s) {
            st = new StringTokenizer(s);
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null)
                    return false;
                eat(s);
            }
            return true;
        }

        public String next() {
            hasNext();
            return st.nextToken();
        }

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

    }
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        Main m = new Main();
        m.run();
        m.out.close();
    }

    void run() throws IOException {
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        long[][] r = new long[n][m - 1];
        long[][] d = new long[n - 1][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m - 1; j++) {
                r[i][j] = nextInt();
            }
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < m; j++) {
                d[i][j] = nextInt();
            }
        }
        if (k % 2 != 0) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    out.print(-1+" ");
                }
                out.println();
            }
            return;
        }
        long[][][] dp = new long[n][m][k + 1];
        for (int kk = 2; kk <= k; kk += 2)
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    long ans = (long) 1e18;
                    if (i + 1 < n) {
                        ans = Math.min(ans, dp[i + 1][j][kk - 2] + d[i][j]*2);
                    }
                    if (i - 1 > -1) ans = Math.min(ans, dp[i - 1][j][kk - 2] + d[i - 1][j]*2);
                    if (j + 1 < m) ans = Math.min(ans, dp[i][j + 1][kk - 2] + r[i][j]*2);
                    if (j - 1 > -1) ans = Math.min(ans, dp[i][j - 1][kk - 2] + r[i][j - 1]*2);
                    dp[i][j][kk] = ans;
                }
            }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                out.print(dp[i][j][k] + " ");
            }
            out.println();
        }
    }

    int gcd(int a, int b) {
        while (a % b != 0) {
            int h = a % b;
            a = b;
            b = h;
        }
        return b;
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer in = new StringTokenizer("");

    // pairs
    class pil implements Comparable<pil> {
        int first;
        long second;

        pil(int f, long s) {
            this.first = f;
            this.second = s;
        }

        public int compareTo(pil o) {
            if (first != o.first) return Integer.compare(first, o.first);
            return Long.compare(second, o.second);
        }
    }

    class pii implements Comparable<pii> {
        int fi;
        int se;

        pii(int f, int s) {
            se = s;
            fi = f;
        }

        public int compareTo(pii o) {
            if (fi != o.fi) return Integer.compare(fi, o.fi);
            return Integer.compare(se, o.se);
        }
    }

    class pis implements Comparable<pis> {
        int fi;
        String s;

        pis(int f, String s) {
            this.s = s;
            fi = f;
        }

        public int compareTo(pis o) {
            return Integer.compare(fi, o.fi);
        }
    }

    class vert {
        int to;
        int iter;
        int idx;
        int ed;

        vert(int s, int f, int zz, int gg) {
            to = s;
            iter = f;
            idx = zz;
            ed = gg;
        }
    }

    class pll implements Comparable<pll> {
        long first;
        long second;

        pll(long f, long s) {
            this.first = f;
            this.second = s;
        }

        public int compareTo(pll o) {
            if (first != o.first) return Long.compare(first, o.first);
            return Long.compare(second, o.second);
        }
    }

    class pli implements Comparable<pli> {
        long first;
        int second;

        pli(long f, int s) {
            this.first = f;
            this.second = s;
        }

        public int compareTo(pli o) {
            if (first != o.first) return Long.compare(first, o.first);
            return Integer.compare(second, o.second);
        }
    }

    boolean hasNext() throws IOException {
        if (in.hasMoreTokens()) return true;
        String s;
        while ((s = br.readLine()) != null) {
            in = new StringTokenizer(s);
            if (in.hasMoreTokens()) return true;
        }
        return false;
    }

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

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

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

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

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.ObjectInputStream.GetField;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.sound.sampled.ReverbType;

public class N718 {
	static PrintWriter out;
	static Scanner sc;
	static ArrayList<int[]>q,w,x;
	static ArrayList<Integer>adj[];
	static HashSet<Integer>primesH;
	static boolean prime[];
	//static ArrayList<Integer>a;
	static HashSet<Long>tmp;
	static int[][][]dist;
	static boolean[]v;
	static int[]a,b,c,d;
	static Boolean[][]dp;
	static char[][]mp;
	static int A,B,n,m,h,ans,sum;
	//static String a,b;
	static long oo=(long)1e9+7;
	public static void main(String[]args) throws IOException {
		sc=new Scanner(System.in);
		out=new PrintWriter(System.out);
		//A();
		//B();
		//C();
		D();
		//E();
		//F();
		//G();
		out.close();
	}
	  private static void A() throws IOException {
		  int t=ni();
		  while(t-->0) {
				long l=nl();
				if(l%2050!=0)ol(-1);
				else {
					long num=l/2050;
					int cnt=0;
					while(num>0) {
						cnt+=num%10;
						num/=10;
					}
					ol(cnt);

				}
		  }

	   }
		static void B() throws IOException {
			int t=ni();
			while(t-->0) {
				int n=ni(),m=ni();
				int[][]a=nmi(n,m);
				PriorityQueue<int[]>pq=new PriorityQueue<int[]>((u,v)->u[0]-v[0]);
				ArrayList<Integer>[]nums=new ArrayList[n];
				for(int i=0;i<n;i++) {
					//nums[i]=new ArrayList<Integer>();
					for(int j=0;j<m;j++) {
						///nums[i].add(a[i][j]);
						pq.add(new int[] {a[i][j],i});
					}
				}
				int[][]ans=new int[n][m];
				for(int i=0;i<m;i++) {
					int[]x=pq.poll();
					ans[x[1]][i]=x[0];
				}
				int []indices=new int[n];
				while(!pq.isEmpty()) {
					int[]x=pq.poll();
					int i=x[1];
					while(ans[i][indices[i]]!=0) {
						indices[i]++;
					}
					ans[i][indices[i]]=x[0];
				}
				for(int i=0;i<n;i++) {
					for(int j=0;j<m;j++) {
						out.print(ans[i][j]+" ");
					}
					ol("");
				}
			}
		}

		static void C() throws IOException{
			 int t=1;
			 while(t-->0) {
				 int n=ni();
				 a=nai(n);
				 int[][]ans=new int[n][n];
				 for(int i=0;i<n;i++)ans[i][i]=a[i];
				 for(int i=n-1;i>=0;i--) {
					 int j=i,k=i;
					 int cur=ans[i][i];
					 cur--;
					 while(cur>0) {
						 j++;
						 if(j>=n||ans[j][k]!=0) {
							 j--;
							 k--;
						 }
						 ans[j][k]=ans[i][i];
						 cur--;
					 }
				 }
				 for(int i=0;i<n;i++) {
					 for(int j=0;j<=i;j++) {
						 out.print(ans[i][j]+" ");
					 }
					 ol("");
				 }
			 }
		}
		private static Boolean dp(int i, int j) {
			if(j>sum/2)return false;
			if(i==x.size()) {
				return sum/2==j;
			}
			if(dp[i][j]!=null)return dp[i][j];

			return dp[i][j]=dp(i+1,j+x.get(i)[0])||dp(i+1,j);
		}
		static boolean isPrime(long n) {
			if(n==2)return true;
			if(n<2||n%2==0)return false;

			for(long i=3L;i*i<n;i+=2l) {
				long rem=(n%i);
				if(rem==0)return false;
			}
			return true;
		}
		static void D() throws IOException {
			int t=1;
			while(t-->0) {
				int n=ni(),m=ni(),k=ni();
				int[][]ans=new int[n][m];
				dist=new int[n][m][4];
				for(int i=0;i<n;i++)for(int j=0;j>m;j++)
					Arrays.fill(dist[i][j], Integer.MAX_VALUE);
				int x;
				for(int i=0;i<n;i++) {
					for(int j=0;j<m-1;j++) {
						dist[i][j][2]=(x=ni());
						dist[i][j+1][3]=x;
					}
				}
				for(int i=0;i<n-1;i++) {
					for(int j=0;j<m;j++) {
						dist[i][j][1]=(x=ni());
						dist[i+1][j][0]=x;
					}
				}
				int[][]nans=new int[n][m];
				if(k%2==1) {
					for(int i=0;i<n;i++)Arrays.fill(ans[i], -1);
				}else {
					for(int ii=0;ii<k/2;ii++) {
					for(int i=0;i<n;i++) {

						for(int j=0;j<m;j++) {
							nans[i][j]=Integer.MAX_VALUE;
							if(i>0)
								nans[i][j]=Math.min(nans[i][j], ans[i-1][j]+dist[i-1][j][1]);
							if(i<n-1)
								nans[i][j]=Math.min(nans[i][j], ans[i+1][j]+dist[i+1][j][0]);
							if(j>0)
								nans[i][j]=Math.min(nans[i][j], ans[i][j-1]+dist[i][j-1][2]);
							if(j<m-1)
								nans[i][j]=Math.min(nans[i][j], ans[i][j+1]+dist[i][j+1][3]);
						}
					}
					int[][]tmp=ans;
					ans=nans;
					nans=tmp;
					}
				}
				for(int i=0;i<n;i++) {
					for(int j=0;j<m;j++) {
						if(ans[i][j]!=-1)ans[i][j]*=2;
						out.print(ans[i][j]+" ");
					}
					ol("");
				}
			}
		}
		private static int bfs(int i, int j,int k) {
			boolean [][]vis=new boolean[dist.length][dist[0].length];
			Queue<int[]>q=new LinkedList<int[]>();
			int mn=Integer.MAX_VALUE;
			q.add(new int[] {i,j,0,0});
			int[]dx=new int[] {-1,1,0,0};
			int[]dy=new int[] {0,0,1,-1};
			while(!q.isEmpty()) {
				int []x=q.poll();
				vis[x[0]][x[1]]=true;
				int c=x[2];
				if(c>k/2)continue;
				if(c>0&&k%c==0&&(k/c)%2==0) {
					mn=Math.min(mn,x[3]*k/c );
				}
				for(int a=0;a<4;a++) {
					int nx=x[0]+dx[a];
					int ny=x[1]+dy[a];
					if(valid(nx,ny)&&!vis[nx][ny]) {
						q.add(new int[] {nx,ny,c+1,x[3]+dist[x[0]][x[1]][a]});
					}
				}

			}
			return mn;
		}
		private static boolean valid(int nx, int ny) {
			return nx>=0&&nx<dist.length&&ny>=0&&ny<dist[0].length;
		}
		static int gcd (int a, int b) {
		    return b==0?a:gcd (b, a % b);
		}

	static void E() throws IOException {
		int t=ni();
		while(t-->0) {

		}

	}

	static void F() throws IOException {
		int t=ni();
		while(t-->0) {

		}
	}
	static void CC() throws IOException {
		for(int kk=2;kk<21;kk++) {
			ol(kk+"   -------");
		int n=kk;
		int k=n-2;
		int msk=1<<k;
		int[]a=new int[k];
		for(int i=0;i<a.length;i++)a[i]=i+2;
		int mx=1;
		int ms=0;
		for(int i=1;i<msk;i++) {
			long prod=1;
			int cnt=0;
			for(int j=0;j<a.length;j++) {
				if(((i>>j)&1)!=0) {
					prod*=a[j];
					cnt++;
				}
			}
			if(cnt>=mx&&prod%n==1) {
				mx=cnt;
				ms=i;
			}

		}
		ol(mx==1?mx:mx+1);
		out.print(1+" ");
		long pr=1;
		for(int j=0;j<a.length;j++) {
			if(((ms>>j)&1)!=0) {
				out.print(a[j]+" ");
				pr*=a[j];
			}
		}
		ol("");
		ol("Prod: "+pr);
		ol(n+"*"+((pr-1)/n)+" + "+1);
		}
	}
	static int ni() throws IOException {
		return sc.nextInt();
	}
	static double nd() throws IOException {
		return sc.nextDouble();
	}
	static long nl() throws IOException {
		return  sc.nextLong();
	}
	static String ns() throws IOException {
		return sc.next();
	}
	static int[] nai(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		return a;
	}
	static long[] nal(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		return a;
	}
	static int[][] nmi(int n,int m) throws IOException{
		int[][]a=new int[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextInt();
			}
		}
		return a;
	}

	static long[][] nml(int n,int m) throws IOException{
		long[][]a=new long[n][m];
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				a[i][j]=sc.nextLong();
			}
		}
		return a;
	}
	static void o(String x) {
		out.print(x);
	}
	static void ol(String x) {
		out.println(x);
	}
	static void ol(int x) {
		out.println(x);
	}
	static void disp1(int []a) {
		for(int i=0;i<a.length;i++) {
			out.print(a[i]+" ");
		}
		out.println();
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

	}
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.io.*;

public class ExplorerSpace {

	private 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;
	    }

	 }

	public static int[][][] dp;

	public static boolean valid(int i, int j, int n, int m)
	{
		return i>=0 && i<n &&j>=0 && j<m;
	}

	public static void solution(int n, int m, int k, int[][] h, int[][] v)

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

				out.println();

			}

			return;
		}

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

		for(int t = 1; t<=k/2; t++)
		{
			for(int i = 0; i<n; i++)
			{
				for(int j = 0; j<m; j++)
				{
					dp[i][j][t] = Integer.MAX_VALUE;

				}
			}
		}

		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<m; j++)
			{
				dp[i][j][0] = 0;

			}
		}

		for(int t = 1; t<=k/2; t++)
		{
			for(int i = 0; i<n; i++)
			{
				for(int j = 0; j<m; j++)
				{
					if(valid(i,j+1,n,m))
						dp[i][j][t] = Math.min(dp[i][j][t], h[i][j] + dp[i][j+1][t-1]);

					if(valid(i,j-1,n,m))
						 dp[i][j][t] = Math.min(dp[i][j][t], h[i][j-1] + dp[i][j-1][t-1]);

					if(valid(i+1,j,n,m))
						 dp[i][j][t] = Math.min(dp[i][j][t], v[i][j] + dp[i+1][j][t-1]);

					if(valid(i-1,j,n,m))
						dp[i][j][t] = Math.min(dp[i][j][t], v[i-1][j] + dp[i-1][j][t-1]);

				}
			}
		}

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

			out.println();
		}

	}

private static PrintWriter out = new PrintWriter(System.out);

public static void main (String[] args)
{
	MyScanner s =  new MyScanner();

    int n = s.nextInt();
    int m = s.nextInt();
    int k = s.nextInt();

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

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

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

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

   solution(n,m,k,h,v);

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

}
}


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

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]),k=Integer.parseInt(s[2]);
        int i,j,max=n*m,in[][]=new int[n][m],x=0;
        if(k%2==1)  //not possible
        {
            for(i=0;i<n;i++)
            {
                for(j=0;j<m;j++) sb.append("-1 ");
                sb.append("\n");
            }
            System.out.print(sb);
            return;
        }

        for(i=0;i<n;i++)
        for(j=0;j<m;j++) in[i][j]=x++;

        ArrayList<Edge> g[]=new ArrayList[max];
        for(i=0;i<max;i++) g[i]=new ArrayList<>();
        for(i=0;i<n;i++)
        {
            s=bu.readLine().split(" ");
            for(j=0;j<m-1;j++)
            {
                int u=in[i][j],v=in[i][j+1],w=Integer.parseInt(s[j]);
                g[u].add(new Edge(v,w));
                g[v].add(new Edge(u,w));
            }
        }
        for(i=0;i<n-1;i++)
        {
            s=bu.readLine().split(" ");
            for(j=0;j<m;j++)
            {
                int u=in[i][j],v=in[i+1][j],w=Integer.parseInt(s[j]);
                g[u].add(new Edge(v,w));
                g[v].add(new Edge(u,w));
            }
        }

        k/=2;
        int dp[][]=new int[k][max];
        for(i=0;i<max;i++)
        {
            dp[0][i]=Integer.MAX_VALUE;
            for(Edge e:g[i])
            dp[0][i]=Math.min(dp[0][i],2*e.w);
        }

        for(i=1;i<k;i++)
        for(j=0;j<max;j++)
        {
            dp[i][j]=Integer.MAX_VALUE;
            for(Edge e:g[j])
            dp[i][j]=Math.min(dp[i][j],dp[i-1][e.v]+2*e.w);
        }

        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            sb.append(dp[k-1][in[i][j]]+" ");
            sb.append("\n");
        }
        System.out.print(sb);
    }

    static class Edge
    {
        int v,w,d;
        Edge(int a,int b)
        {
            v=a;
            w=b;
            d=0;
        }
    }
}


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

/**
 * A simple template for competitive programming problems.
 */
public class Solution {
    //InputReader in = new InputReader("input.txt");
    final InputReader in = new InputReader(System.in);

    final PrintWriter out = new PrintWriter(System.out);

    int n,m;

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

        int[][] hor = new int[n][m-1];
        int[][] ver = new int[n-1][m];

        for(int i=0; i<n; i++) {
            for(int j=0; j<m-1; j++) {
                hor[i][j] = in.nextInt(); //hor[i][j]=mat[i][j] -> mat[i][j+1]
            }
        }

        for(int i=0; i<n-1; i++) {
            for(int j=0; j<m; j++) {
                ver[i][j] = in.nextInt(); //ver[i][j]= mat[i][j] -> mat[i+1][j]
            }
        }

        int[][] ans = new int[n][m];

        if(k%2==1) {
            for(int i=0; i<n; i++)
                Arrays.fill(ans[i], -1);
        } else {
            for(int dummy=0; dummy<k>>1; dummy++) {
                int[][] newAns = new int[n][m];
                for(int i=0; i<n; i++) {
                    Arrays.fill(newAns[i], Integer.MAX_VALUE);
                    for(int j=0; j<m; j++) {
                        if(isGood(i+1, j)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*ver[i][j] + ans[i+1][j]);
                        }
                        if(isGood(i, j+1)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*hor[i][j] + ans[i][j+1]);
                        }
                        if(isGood(i, j-1)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*hor[i][j-1] + ans[i][j-1]);
                        }
                        if(isGood(i-1, j)) {
                            newAns[i][j] = Math.min(newAns[i][j], 2*ver[i-1][j] + ans[i-1][j]);
                        }
                    }
                }
                ans = newAns;
            }
        }

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

    boolean isGood(int i, int j) {
        return i>=0 && i<n && j>=0 && j<m;
    }

    private void shuffle(int[] a) {
        int n = a.length;
        Random random = new Random();
        random.nextInt();
        for (int i = 0; i < n; i++) {
            int change = i + random.nextInt(n - i);
            swap(a, i, change);
        }
    }

    private static void swap(int[] a, int i, int change) {
        int helper = a[i];
        a[i] = a[change];
        a[change] = helper;
    }

    public static void main(final String[] args) throws FileNotFoundException {
        final Solution s = new Solution();
        final Long t1 = System.currentTimeMillis();
        s.solve();
        System.err.println(System.currentTimeMillis() - t1 + " ms");
        s.out.close();
    }

    public Solution() throws FileNotFoundException {
    }

    private static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        Random r = new Random();
        InputReader(final InputStream stream) {
            this.stream = stream;
        }

        InputReader(final String fileName) {
            InputStream stream = null;
            try {
                stream = new FileInputStream(fileName);
            } catch (final FileNotFoundException e) {
                e.printStackTrace();
            }
            this.stream = stream;
        }

        int[] nextArray(final int n) {
            final int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt();
            return arr;
        }

        int[][] nextMatrix(final int n, final int m) {
            final int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < m; j++)
                    matrix[i][j] = nextInt();
            return matrix;
        }

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

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

        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;
        }

        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;
        }

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

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

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

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

}


import java.util.*;
import java.util.Map.Entry;

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

public class Main {
	static int[][] to = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };

	public static void main(String[] args) throws FileNotFoundException {
		InputReader in = new InputReader(System.in);
		// Scanner in = new Scanner(System.in);
		// Scanner in = new Scanner(new BufferedReader(new
		// InputStreamReader(System.in)));
		PrintWriter out = new PrintWriter(System.out);
		// InputReader in = new InputReader(new
		// File("ethan_traverses_a_tree.txt"));
		// PrintWriter out = new PrintWriter(new
		// File("ethan_traverses_a_tree-output.txt"));

		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();

		int[][][] cost = new int[n][m][4];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m - 1; j++) {
				int u = in.nextInt();
				cost[i][j][1] = u;
				cost[i][j + 1][3] = u;
			}
		}

		for (int i = 0; i < n - 1; i++) {
			for (int j = 0; j < m; j++) {
				int u = in.nextInt();
				cost[i][j][0] = u;
				cost[i + 1][j][2] = u;
			}
		}

		if (k % 2 == 0) {
			k = k / 2;
			int[][][] dp = new int[k + 1][n][m];

			for (int i = 0; i <= k; i++) {
				for (int x = 0; x < n; x++) {
					for (int y = 0; y < m; y++) {
						if (i == 0) {
							dp[i][x][y] = 0;
						} else {
							int min = 1000000000;

							for (int way = 0; way < to.length; way++) {
								int nextx = x + to[way][0];
								int nexty = y + to[way][1];

								if (nextx >= 0 && nextx < n && nexty >= 0 && nexty < m) {
									min = Math.min(min, dp[i - 1][nextx][nexty] + cost[x][y][way]);
								}
							}

							dp[i][x][y] = min;
						}
					}
				}
			}

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

		out.close();
	}

	static class InputReader {
		BufferedReader br;
		StringTokenizer st;

		public InputReader(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public InputReader(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

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

		public boolean hasNext() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

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

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