You are wandering in the explorer space of the 2050 Conference.

The explorer space can be viewed as an undirected weighted grid graph with size n× m. The set of vertices is \{(i, j)|1≤ i≤ n, 1≤ j≤ m\}. Two vertices (i_1,j_1) and (i_2, j_2) are connected by an edge if and only if |i_1-i_2|+|j_1-j_2|=1.

At each step, you can walk to any vertex connected by an edge with your current vertex. On each edge, there are some number of exhibits. Since you already know all the exhibits, whenever you go through an edge containing x exhibits, your boredness increases by x.

For each starting vertex (i, j), please answer the following question: What is the minimum possible boredness if you walk from (i, j) and go back to it after exactly k steps?

You can use any edge for multiple times but the boredness on those edges are also counted for multiple times. At each step, you cannot stay on your current vertex. You also cannot change direction while going through an edge. Before going back to your starting vertex (i, j) after k steps, you can visit (i, j) (or not) freely.

Input

The first line contains three integers n, m and k (2≤ n, m≤ 500, 1≤ k≤ 20).

The j-th number (1≤ j ≤ m - 1) in the i-th line of the following n lines is the number of exibits on the edge between vertex (i, j) and vertex (i, j+1). 

The j-th number (1≤ j≤ m) in the i-th line of the following n-1 lines is the number of exibits on the edge between vertex (i, j) and vertex (i+1, j). 

The number of exhibits on each edge is an integer between 1 and 10^6.

Output

Output n lines with m numbers each. The j-th number in the i-th line, answer_{ij}, should be the minimum possible boredness if you walk from (i, j) and go back to it after exactly k steps.

If you cannot go back to vertex (i, j) after exactly k steps, answer_{ij} should be -1. 

Examples

Input


3 3 10
1 1
1 1
1 1
1 1 1
1 1 1


Output


10 10 10
10 10 10
10 10 10


Input


2 2 4
1
3
4 2


Output


4 4
10 6


Input


2 2 3
1
2
3 4


Output


-1 -1
-1 -1

Note

In the first example, the answer is always 10 no matter how you walk.

In the second example, answer_{21} = 10, the path is (2,1) → (1,1) → (1,2) → (2,2) → (2,1), the boredness is 4 + 1 + 2 + 3 = 10.
#include <iostream>
#include <bits/stdc++.h>
#include <limits>
#include <unordered_map>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <bitset>
 
#define mod 1000000007
#define MAX 1000006
#define int long long
#define endl "\n"
 
using namespace std;
 
 
int max(int a,int b){if(a>=b){return a;}return b;}
int min(int a,int b){if(a<=b){return a;}return b;}
int modpower(int a, int n , int d=mod){int res=1;while(n){if(n%2){res=((res%d)*(a%d))%d;n--;}else{a=((a%d)*(a%d))%d;n/=2;}}return res;} 
int modadd(int a,int b,int d=mod){return ((a%d)+(b%d))%d;}
int modsubtract(int a,int b,int d=mod){return ((a%d)-(b%d))%d;}
int modproduct(int a,int b,int d=mod){return ((a%d)*(b%d))%d;}

int dp[502][502][22];
int n,m;


int recursion(int i,int j,int k,map<pair<int,int>,vector<pair<pair<int,int>,int>>> &mp)
{
    if(i<0 || i>=n || j<0 || j>=m )
    {
        return INT_MAX;
    }
    if(k==0)
    {
        return 0;
    }
    if(dp[i][j][k]!=-1 )
    {
        return dp[i][j][k];
    }
    int ans=INT_MAX;
    for(auto it:mp[{i,j}])
    {
        pair<pair<int,int>,int> p=it;
        ans=min(ans,p.second+recursion(p.first.first,p.first.second,k-1,mp));
    }
    // cout<<i<<" "<<j<<" "<<k<<" "<<ans<<"\n";
    dp[i][j][k]=ans;
    return ans;
}



void solve()
{
    //each edge has 4 movements up down left right.
    int k;
    cin>>n>>m>>k;
    memset(dp,-1,sizeof(dp));
    map<pair<int,int>,vector<pair<pair<int,int>,int>>> mp;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m-1;j++)
        {
            int x;
            cin>>x;
            mp[{i,j}].push_back({{i,j+1},x});
            mp[{i,j+1}].push_back({{i,j},x});
        }
    }
    for(int i=0;i<n-1;i++)
    {
        for(int j=0;j<m;j++)
        {
            int x;
            cin>>x;
            mp[{i,j}].push_back({{i+1,j},x});
            mp[{i+1,j}].push_back({{i,j},x});
        }
    }
    if(k%2==1)
    {
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cout<<-1<<" ";
            }
            cout<<"\n";
        }
        return;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            int w=recursion(i,j,k/2,mp)*2;
            if(w==INT_MAX)
            {
                cout<<"-1 ";
            }
            else
            {
                cout<<w<<" ";
            }
        }
        cout<<"\n";
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=0;j<m;j++)
    //     {
    //         cout<<dp[i][j][k]<<" ";
    //     }
    //     cout<<"\n";
    // }

}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t>0)
    {
        t--;
        solve();
    }
}