#define _USE_MATH_DEFINES
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <nmmintrin.h>
#include <immintrin.h>
#include <mmintrin.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,P) scanf("%d %d %d %d",&n,&m,&o,&P)
#define SINT5(n,m,o,P,q) scanf("%d %d %d %d %d",&n,&m,&o,&P,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1'010'000'000; // 0x3C33'6080
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second


int h, w, s;
int memo[36][36][36][36];
int u[64][64];
int sum_dat[64][64];

int sum(int l, int u, int r, int d) {
	return sum_dat[d][r] - sum_dat[u][r] - sum_dat[d][l] + sum_dat[u][l];
}

// solve : v以上で分割したときにできるグループ数．できないなら0
// グループ数を最大化
int solve(int l, int u, int r, int d, int v) { // [l,r) [u,d)
	if (memo[l][u][r][d] != -1) return memo[l][u][r][d];
	int ret = 0;
	if (sum(l, u, r, d) >= v) ret = 1;
	for (int i = u + 1; i < d; ++i) { // 上下
		int a = solve(l, u, r, i, v);
		int b = solve(l, i, r, d, v);
		ret = max(ret, a + b);
	}
	for (int i = l + 1; i < r; ++i) { // 左右
		int a = solve(l, u, i, d, v);
		int b = solve(i, u, r, d, v);
		ret = max(ret, a + b);
	}
	// printf("Solve LR[%d,%d) UD[%d,%d] : %d\n", l,r,u,d,ret);
	return memo[l][u][r][d] = ret;
}

// solve : v以上で分割したときにできるグループ数．できないなら0
// test : v以上に分割できるか．できるならグループ数
int test(int v) {
	memset(memo, -1, sizeof(memo));
	auto ret = solve(0, 0, w, h, v);
	return ret;
}


int main() {
	while (cin >> h >> w >> s, h) {
		memset(sum_dat, 0, sizeof(sum_dat));
		rep(i, h) rep(j, w) {
			cin >> u[i][j];
			sum_dat[i + 1][j + 1] = u[i][j];
		}
		reP(i, h) {
			reP(j, w) {
				sum_dat[i][j + 1] += sum_dat[i][j];
			}
		}
		reP(i, h) {
			reP(j, w) {
				sum_dat[i + 1][j] += sum_dat[i][j];
			}
		}
		/*
		puts("~~~~~");
		reP(i, h) {
			reP(j, w) {
				printf("%2d ", sum_dat[i][j]);
			}
			puts("");
		}
		//*/
		int mi = sum_dat[h][w] - s;
		int miv = test(mi);
		int ok = mi;
		int ng = sum_dat[h][w] + 1;

		while (ng - ok > 1) {
			int m = (ok + ng) / 2;
			if (test(m) != miv) {
				ng = m;
			} else {
				ok = m;
			}
		}
		cout << miv << " " << ok-mi << endl;


		/*
		rep(i, h) rep(j, w) {
			printf("[%d,%d]\n", i, j);
			repfT(a, 1, h) {
				repfT(b, 1, w) {
					int r = -1;
					if (i < a && j < b) {
						r = sum(j, i, b, a);
					}
					printf("%2d ", r);
				}
				puts("");
			}
			puts("");
		}
		puts("----");
		//*/

		/*
		for (;;) {
			int v;
			cin >> v;
			cout << v << " : " << test(v) << endl;

			rep(i, h) rep(j, w) {
				printf("[%d,%d]\n", i, j);
				repfT(a, 1, h){
					repfT(b, 1, w) {
						if (i < a && j < b) {
							int r = solve(j, i, b, a, v);
							printf("%2d ", r);
						} else {
							printf(" # ");
						}
					}
					puts("");
				}
				puts("");
			}
		}
		*/

	}

}





Measured memory_bytes: 9672