#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define rep(i,from,to) for(int i=from; i<to; ++i)
#define REP(i,from,to) for(int i=from; i<=to; ++i)
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> area;
typedef struct answer answer;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

struct answer {
	int group, yobi;
	answer(int group, int yobi) {
		this->group = group;
		this->yobi = yobi;
	}
	answer() {
		*this = answer(1, 0);
	}
	bool operator<(const answer& a) const {
		if (group == a.group) {
			return yobi < a.yobi;
		} else {
			return group < a.group;
		}
	}
	bool operator==(const answer& a) const {
		return group == a.group && yobi == a.yobi;
	}
	bool operator!=(const answer& a) const {
		return !(*this == a);
	}
};

int h, w, s;
const int maxh = 33;
int g[maxh][maxh];
int sum[maxh][maxh];
int total;
answer dp[maxh][maxh][maxh][maxh];
const answer INIT = answer(1, 0);
int totalpower(area a) {
	P &p1 = a.first, &p2 = a.second;
	int i1 = p1.first, j1 = p1.second;
	int i2 = p2.first, j2 = p2.second;
	return sum[i2][j2] - sum[i1 - 1][j2] - sum[i2][j1 - 1] + sum[i1 - 1][j1 - 1];
}

answer dfs(area a, int restpower) { //rest: ???????????????
	P &p1 = a.first, &p2 = a.second;
	int i1 = p1.first, j1 = p1.second;
	int i2 = p2.first, j2 = p2.second;
//	printf("area: (%d, %d) , (%d, %d)\nrestpower: %d\n\n", i1, j1, i2, j2,
//			restpower);
	if (dp[i1][j1][i2][j2] != INIT) {
		return dp[i1][j1][i2][j2];
	}
	answer ret = answer(1, restpower);
	rep(j, j1, j2)
	{
		area left = area(P(i1, j1), P(i2, j));
		area right = area(P(i1, j + 1), P(i2, j2));
		int powL = totalpower(left), powR = totalpower(right);
		int restL = restpower - powR, restR = restpower - powL;
		if (restL >= 0 && restR >= 0) {
			answer L = dfs(left, restL);
			answer R = dfs(right, restR);
			answer tmp = answer(L.group + R.group, min(L.yobi, R.yobi));
			ret = max(ret, tmp);
		}
	}

	rep(i, i1, i2)
	{
		area upper = area(P(i1, j1), P(i, j2));
		area down = area(P(i + 1, j1), P(i2, j2));
		int powP = totalpower(upper), powN = totalpower(down);
		int restP = restpower - powN, restN = restpower - powP;
		if (restP >= 0 && restN >= 0) {
			answer UP = dfs(upper, restP);
			answer DOWN = dfs(down, restN);
			answer tmp = answer(UP.group + DOWN.group, min(UP.yobi, DOWN.yobi));
			ret = max(ret, tmp);
		}
	}
	return dp[i1][j1][i2][j2] = ret;
}

void init() {
	memset(g, 0, sizeof(g));
	memset(sum, 0, sizeof(sum));
	rep(i1,0,maxh)
	{
		rep(j1,0,maxh)
		{
			rep(i2,0,maxh)
			{
				rep(j2,0,maxh)
				{
					dp[i1][j1][i2][j2] = INIT;
				}
			}
		}
	}
}
void solve() {
	while (cin >> h >> w >> s, h || w || s) {
		init();
		vector<area> sep;
		REP(i, 1, h)
		{
			REP(j,1,w)
			{
				cin >> g[i][j];
			}
		}
		sum[1][1] = g[1][1];
		REP(i, 1, h)
		{
			REP(j,1,w)
			{
				if (i == 1 && j == 1) {
					continue;
				}
				sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]
						+ g[i][j];
			}
		}
		area whole = area(P(1, 1), P(h, w));
		total = totalpower(whole);
		answer ans = dfs(whole, s);
//		cout << "group: " << ans.group << endl;
//		cout << "yobi: " << ans.yobi << endl;
		cout << ans.group << " " << ans.yobi << endl;
	}

}

int main() {
	solve();
}

Measured memory_bytes: 12368