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:
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int H, W, N;
	cin >> H >> W >> N;
	vector<vector<int> > s(H + 1, vector<int>(W + 1));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> s[i + 1][j + 1];
			s[i + 1][j + 1] += s[i + 1][j] + s[i][j + 1] - s[i][j];
		}
	}
	function<int(int, int, int, int)> sum = [&](int xa, int ya, int xb, int yb) {
		return s[xa][ya] + s[xb][yb] - s[xa][yb] - s[xb][ya];
	};
	function<int(int, int, int, int)> solve2 = [&](int xa, int ya, int xb, int yb) {
		int res = 0;
		for (int i = xa + 1; i <= xb - 1; ++i) {
			res = max(res, min(sum(xa, ya, i, yb), sum(i, ya, xb, yb)));
		}
		for (int i = ya + 1; i <= yb - 1; ++i) {
			res = max(res, min(sum(xa, ya, xb, i), sum(xa, i, xb, yb)));
		}
		return res;
	};
	function<int(int, int, int, int)> solve3 = [&](int xa, int ya, int xb, int yb) {
		int res = 0;
		for (int i = xa + 1; i <= xb - 1; ++i) {
			res = max(res, min(sum(xa, ya, i, yb), solve2(i, ya, xb, yb)));
			res = max(res, min(solve2(xa, ya, i, yb), sum(i, ya, xb, yb)));
		}
		for (int i = ya + 1; i <= yb - 1; ++i) {
			res = max(res, min(sum(xa, ya, xb, i), solve2(xa, i, xb, yb)));
			res = max(res, min(solve2(xa, ya, xb, i), sum(xa, i, xb, yb)));
		}
		return res;
	};
	if (N == 2) cout << solve2(0, 0, H, W) << '\n';
	if (N == 3) cout << solve3(0, 0, H, W) << '\n';
	if (N == 4) {
		int res = 0;
		for (int i = 1; i <= H - 1; ++i) {
			res = max(res, min(sum(0, 0, i, W), solve3(i, 0, H, W)));
			res = max(res, min(solve2(0, 0, i, W), solve2(i, 0, H, W)));
			res = max(res, min(solve3(0, 0, i, W), sum(i, 0, H, W)));
		}
		for (int i = 1; i <= W - 1; ++i) {
			res = max(res, min(sum(0, 0, H, i), solve3(0, i, H, W)));
			res = max(res, min(solve2(0, 0, H, i), solve2(0, i, H, W)));
			res = max(res, min(solve3(0, 0, H, i), sum(0, i, H, W)));
		}
		for (int i = 1; i <= W - 1; ++i) {
			for (int j = i + 1; j <= W - 1; ++j) {
				vector<int> ax(H - 1), ay(H - 1);
				for (int k = 1; k <= H - 1; ++k) {
					ax[k - 1] = min(sum(0, j, k, W), sum(k, i, H, W));
					ay[k - 1] = min(sum(0, i, k, W), sum(k, j, H, W));
				}
				int curx = 0;
				for (int k = 0; k <= H - 2; ++k) {
					curx = max(curx, min(sum(0, 0, k, j), sum(k, 0, H, i)));
					res = max(res, min(ax[k], curx));
				}
				int cury = 0;
				for (int k = H - 2; k >= 0; --k) {
					cury = max(cury, min(sum(0, 0, k + 1, i), sum(k + 1, 0, H, j)));
					res = max(res, min(ay[k], cury));
				}
			}
		}
		cout << res << '\n';
	}
	return 0;
}