#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

pair<int, int> ans[32][32][32][32];
int val[32][32] = {};

int grid_val(pair<int, int> left, pair<int, int> right) {
	int ans = val[right.first][right.second];
	if (left.first != 0) {
		ans -= val[left.first - 1][right.second];
	}
	if (left.second != 0) {
		ans -= val[right.first][left.second - 1];
	}
	if (left.first != 0 && left.second != 0) {
		ans += val[left.first - 1][left.second - 1];
	}
	return ans;
}

int s;

pair<int, int> dfs(pair<int, int> left, pair<int, int> right) {
	if (ans[left.first][left.second][right.first][right.second].second != 1e9) return ans[left.first][left.second][right.first][right.second];
	//yoko
	pair<int, int> final_ans = mp(1, grid_val(left,right) - s);
	for (int q = left.first + 1; q <= right.first; ++q) {
		if (grid_val(mp(left.first, left.second), mp(q - 1, right.second)) >= s) {
			if (grid_val(mp(q, left.second), mp(right.first, right.second)) >= s) {
				pair<int, int> now = dfs(mp(left.first, left.second), mp(q - 1, right.second));
				pair<int,int> tmp = dfs(mp(q, left.second), mp(right.first, right.second));
				now.first += tmp.first;
				now.second = min(tmp.second,now.second);
				if (final_ans.first < now.first||(final_ans.first == now.first&&final_ans.second < now.second)) {
					final_ans = now;
				}
			}
		}
	}
	for (int q = left.second + 1; q <= right.second; ++q) {
		if (grid_val(mp(left.first, left.second), mp(right.first, q-1)) >= s) {
			if (grid_val(mp(left.first,q), mp(right.first, right.second)) >= s) {
				pair<int, int> now = dfs(mp(left.first, left.second), mp(right.first, q - 1));
				pair<int, int> tmp = dfs(mp(left.first, q), mp(right.first, right.second));
				now.first += tmp.first;
				now.second = min(tmp.second, now.second);
				if (final_ans.first < now.first || (final_ans.first == now.first && final_ans.second < now.second)) {
					final_ans = now;
				}
			}
		}
	}
	return ans[left.first][left.second][right.first][right.second] = final_ans;
}

void solve(){
	vector<pair<int, int>> final_ans;
	while (true) {
		int h, w;
		cin >> h >> w >> s;
		if (h == 0) {
			REP(i, final_ans.size()) {
				cout << final_ans[i].first << " " << final_ans[i].second << endl;
			}
			return;
		}
		REP(q, h) {
			REP(j, w) {
				REP(t, h) {
					REP(p, w) {
						ans[q][j][t][p] = mp(0, 1e9);
					}
				}
			}
		}
		REP(i, h) {
			REP(q, w) {
				cin >> val[i][q];
				if (q != 0) val[i][q] += val[i][q - 1];
			}
		}
		REP(q, w) {
			for (int i = 1; i < h; ++i) {
				val[i][q] += val[i - 1][q];
			}
		}
		s = val[h - 1][w - 1] - s;
		pair<int, int> ans = dfs(mp(0, 0), mp(h - 1, w - 1));
		final_ans.push_back(ans);
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 11340