#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int a[209][209], b[209][209], H, W, N, maxn;

void ruisekiwa() {
	for (int i = 0; i < 209 * 209; i++) b[i / 209][i % 209] = 0;
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) b[i][j] = a[i][j]; }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { b[i][j] += b[i - 1][j]; } }
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { b[i][j] += b[i][j - 1]; } }
}

void hanten() {
	for (int i = 1; i <= max(H, W); i++) {
		for (int j = 1; j <= max(H, W); j++) { if (i < j) swap(a[i][j], a[j][i]); }
	}
	swap(H, W);
}

int ranged(int px, int py, int qx, int qy) {
	return b[px - 1][py - 1] + b[qx][qy] - b[px - 1][qy] - b[qx][py - 1];
}

int P[209][209];

int calc(vector<int>G, int R) {
	for (int i = 0; i < 209 * 209; i++) P[i / 209][i % 209] = 0;
	for (int i = 0; i < G.size(); i++) {
		int sum = 0;
		for (int j = i; j < G.size(); j++) {
			sum += G[j]; P[i][j] = sum;
		}
	}
	int ret = 0;
	if (R == 1) return P[0][G.size() - 1];
	if (R == 2) {
		for (int i = 1; i < G.size(); i++) ret = max(ret, min(P[0][i - 1], P[i][G.size() - 1]));
		return ret;
	}
	if (R == 3) {
		for (int i = 1; i < G.size(); i++) {
			for (int j = i + 1; j < G.size(); j++) {
				ret = max(ret, min({ P[0][i - 1], P[i][j - 1], P[j][G.size() - 1] }));
			}
		}
		return ret;
	}
	if (R == 4) {
		for (int i = 1; i < G.size(); i++) {
			for (int j = i + 1; j < G.size(); j++) {
				for (int k = j + 1; k < G.size(); k++) {
					ret = max(ret, min({ P[0][i - 1], P[i][j - 1], P[j][k - 1], P[k][G.size() - 1] }));
				}
			}
		}
		return ret;
	}
}

int dfs(int px, int py, int qx, int qy, int life) {
	if (life == 1) return ranged(px, py, qx, qy);
	else {
		int rem = 0;
		for (int t = 1; t < life; t++) {
			for (int i = px + 1; i <= qx; i++) {
				int V1 = dfs(px, py, i - 1, qy, t);
				int V2 = dfs(i, py, qx, qy, life - t);
				rem = max(rem, min(V1, V2));
			}
			for (int j = py + 1; j <= qy; j++) {
				int V1 = dfs(px, py, qx, j - 1, t);
				int V2 = dfs(px, j, qx, qy, life - t);
				rem = max(rem, min(V1, V2));
			}
		}
		return rem;
	}
}

void solve() {
	int Z = dfs(1, 1, H, W, N);
	maxn = max(maxn, Z);

	if (N == 4) {
		for (int i = 2; i <= H - 1; i++) {
			for (int j = 2; j <= W - 1; j++) {
				for (int k = i; k <= H - 1; k++) {
					for (int l = j; l <= W - 1; l++) {
						int V1 = ranged(1, 1, k, j - 1);
						int V2 = ranged(k + 1, 1, H, l);
						int V3 = ranged(i, l + 1, H, W);
						int V4 = ranged(1, j, i - 1, W);
						maxn = max(maxn, min({ V1, V2, V3, V4 }));
					}
				}
			}
		}
	}
}

int main() {
	cin >> H >> W >> N;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> a[i][j];
	}
	ruisekiwa();
	solve();
	hanten(); ruisekiwa();
	solve();
	cout << maxn << endl;
	return 0;
}

