#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; }
#endif
#ifdef __GNUC__
template <class T> int popcount(T n);
template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; }
template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

template <class T> void print(T a, int n, int br = 1, const string& deli = ", ") { cout << "{ "; for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } cout << " }"; while (br--) cout << endl; }
template <class T> void print(const vector<T>& v, int br = 1, const string& deli = ", ") { print(v, v.size(), br, deli); }



int sum[40][40];
template <class T, class U>
void calc_sq_sum(T res, U data, int w, int h)
{
	for (int y = 0; y <= h; ++y)
		res[y][0] = 0;
	for (int x = 0; x <= w; ++x)
		res[0][x] = 0;
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
			res[y + 1][x + 1] = res[y][x + 1] + res[y + 1][x] - res[y][x] + data[y][x];
}
template <class U, class T>
U sq_sum(T sum, int x1, int y1, int x2, int y2)
{
	return sum[y2 + 1][x2 + 1] + sum[y1][x1] - (sum[y2 + 1][x1] + sum[y1][x2 + 1]);
}
//template <class T, class U>
//U sq_sum_by_size(T res, int x, int y, int w, int h)
//{
//	return sq_sum(res, x, y, x + w - 1, y + h - 1);
//}

int h, w, s, u[40][40];
int total_power;
int group[40][40][40][40], power[40][40][40][40];
void recur(int x1, int y1, int x2, int y2)
{
	int& g = group[x1][y1][x2][y2];
	int& p = power[x1][y1][x2][y2];
	if (g != -1)
		return;
	else if (total_power - sq_sum<int>(sum, x1, y1, x2, y2) > s)
	{
		g = -(1 << 24);
		return;
	}

	g = 1;
	p = sq_sum<int>(sum, x1, y1, x2, y2);
	for (int x = x1; x < x2; ++x)
	{
		recur(x1, y1, x, y2);
		recur(x + 1, y1, x2, y2);

		int tg = group[x1][y1][x][y2] + group[x + 1][y1][x2][y2];
		int tp = min(power[x1][y1][x][y2], power[x + 1][y1][x2][y2]);
		if (tg > g || tg == g && tp > p)
			g = tg, p = tp;
	}
	for (int y = y1; y < y2; ++y)
	{
		recur(x1, y1, x2, y);
		recur(x1, y + 1, x2, y2);

		int tg = group[x1][y1][x2][y] + group[x1][y + 1][x2][y2];
		int tp = min(power[x1][y1][x2][y], power[x1][y + 1][x2][y2]);
		if (tg > g || tg == g && tp > p)
			g = tg, p = tp;
	}
}
int main()
{
	ios::sync_with_stdio(false);

	while (cin >> h >> w >> s, h)
	{
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				cin >> u[i][j];
		calc_sq_sum(sum, u, w, h);
		total_power = sq_sum<int>(sum, 0, 0, w - 1, h - 1);

		CL(group, -1);
		recur(0, 0, w - 1, h - 1);

		int g = group[0][0][w - 1][h - 1];
		int p = s - (total_power - power[0][0][w - 1][h - 1]);
		cout << g << " " << p << endl;
	}
}

Measured memory_bytes: 16000