Problem: F --Land inheritance

Problem Statement

One $ N $ brother was discussing the inheritance of his parents. The vast heritage left by their parents included vast lands. The land has a rectangular shape extending $ H $ km from north to south and $ W $ km from east to west. This land is managed in units of 1 km square, 1 km square within the range of $ i $ to $ i + 1 $ km from the north end of the land and $ j $ to $ j + 1 $ km from the west end. The partition is called partition $ (i, j) $. ($ i $, $ j $ is an integer that satisfies $ 0 \ leq i <H $, $ 0 \ leq j <W $.) The land price is fixed for each lot, and the lot $ (i, j) $ The price of is represented by $ a_ {i, j} $.

The brothers decided to divide the land and inherit it as follows.

* $ N $ Each of the siblings chooses some parcels and inherits them.
* The parcels must be chosen so that the land inherited by each sibling forms a rectangle.
* $ N $ Lands inherited by brothers must not overlap.
* There may be compartments where no one inherits. The parcels that no one inherits are abandoned.



The sum of the prices of the lots included in the range of land inherited by a person is called the price of the land. The brothers want to divide the land so that the price of the land they inherit is as fair as possible. Your job is to think of ways to divide the land that maximizes the price of the land of the person with the lowest inherited land price among the $ N $ people. Create a program that answers the land price of the person with the lowest inherited land price when the land is divided in this way.

Input

The input is given in the following format.

$ H $ $ W $ $ N $
$ a_ {0,0} $ $ a_ {0,1} $ ... $ a_ {0, W-1} $
...
$ a_ {H-1,0} $ $ a_ {H-1,1} $ ... $ a_ {H-1, W-1} $

$ H $, $ W $$ (2 \ leq H, W \ leq 200) $ represent the north-south length and the east-west length of the heritage land, respectively. $ N $$ (2 \ leq N \ leq 4) $ represents the number of siblings who inherit the land. $ a_ {i, j} $$ (0 \ leq a_ {i, j} \ leq 10 ^ 4) $ represents the price of the partition $ (i, j) $.

Output

Output the lowest land price in one line when the land price of the person with the lowest inherited land price is divided so as to maximize the land price.

Sample Input 1


3 3 2
1 2 2
3 1 0
0 4 3

Output for the Sample Input 1


7

It is best to divide as shown in the figure.

<image>


Sample Input 2


3 3 2
0 1 0
1 1 1
0 1 0

Output for the Sample Input 2


1

Sample Input 3


2 5 3
8 3 0 5 6
2 5 2 5 2

Output for the Sample Input 3


11

Sample Input 4


3 3 4
3 3 4
3 3 4
3 3 4

Output for the Sample Input 4


7

Sample Input 5


4 4 4
2 2 2 2
2 1 2 1
2 2 2 2
2 1 2 1

Output for the Sample Input 5


7





Example

Input

3 3 2
1 2 2
3 1 0
0 4 3


Output

7

Solution (in CPP):

Solution:
#ifndef _WIN32
#include<iostream>
#endif
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename T>
bool chmin(T&l, T r) { bool f = l > r; if (f)l = r; return f; }
template<typename T>
bool chmax(T&l, T r) { bool f = l < r; if (f)l = r; return f; }
typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;
#define DCrc(R,C,v) int R=v.size(),C=v[0].size(); 
VV sub(VV x, int t, int b, int l, int r) {
	int R = b - t;
	int C = r - l;
	VV y(R, V(C));
	FOR(i, t, b)FOR(j, l, r)y[i - t][j - l] = x[i][j];
	return y;
}
VV rot(VV x) {
	DCrc(R, C, x);
	VV y(C,V(R));
	REP(i, C)REP(j, R) {
		y[i][j] = x[j][C - i-1];
	}
	return y;
}
VV setsum(VV& x) {
	DCrc(R, C, x);
	VV y(R + 1, V(C + 1, 0));
	REP(i, R)REP(j, C)
		y[i + 1][j + 1] = x[i][j] + y[i + 1][j] + y[i][j + 1] - y[i][j];
	return y;
}
LL getsum(VV &x, int t, int b, int l, int r) {
	return x[b][r] + x[t][l] - x[b][l] - x[t][r];
}
LL f2(VV x) {
	DCrc(R, C, x);
	auto S = setsum(x);
	LL res = 0;
	FOR(i,1, R)chmax(res, min(getsum(S, 0, i, 0, C) ,getsum(S, i, R, 0, C)));
	FOR(i,1, C)chmax(res, min(getsum(S, 0, R, 0, i) ,getsum(S, 0, R, i, C)));
	return res;
}
LL f3(VV x) {
	LL res = 0;
	REP(_, 4) {
		DCrc(R, C, x);
		auto S = setsum(x);
		FOR(i,1, R)FOR(j, i + 1, R)
			chmax(res, min({
			getsum(S, 0, i, 0, C),
			getsum(S, i, j, 0, C),
			getsum(S, j, R, 0, C)
		}));
		FOR(i,1, R)FOR(j,1,C)
			chmax(res, min({
			getsum(S, 0, i, 0, C),
			getsum(S, i, R, 0, j),
			getsum(S, i, R, j, C)
		}));
		x = rot(x);
	}
	return res;
}
LL f4(VV x) {
	LL res = 0;
	REP(_, 4) {
		DCrc(R, C, x);
		auto S = setsum(x);
		FOR(i, 1, R) {
			chmax(res, min(
				getsum(S, 0, i, 0, C),
				f3(sub(x, i, R, 0, C))
				));
		}
		FOR(a, 1, R)FOR(b, 1, C) {
			LL lb = getsum(S, 0, a, 0, b);
			int c = 0;
			int d = 0;

			while (c < C&&getsum(S, a, R, 0, c) < lb)c++;
			while (d < R&&getsum(S, 0, d, b, C) < lb)d++;
			if (c == C || d == R)continue;
			if (d > a&&c > b)continue;
			LL k;
			if (d > a||c > b) {
				k = getsum(S, d, R, c, C);
			}
			else k = max({
				getsum(S, d, R, b, C),
				getsum(S, a, R, c, C)
			});
			chmax(res, min(lb,k));
		}
		x = rot(x);
	}
	return res;
}


int main() {
	int R, C, N;
	cin >> R >> C >> N;
	{
		VV x(R, V(C));
		REP(i, R)REP(j, C)cin >> x[i][j];
		if (N == 2)cout << f2(x) << endl;
		if (N == 3)cout << f3(x) << endl;
		if (N == 4)cout << f4(x) << endl;

	}
	return 0;
}