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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
pii dp[33][33][33][33];
int h,w,s;
int vv[33][33];
int lim;
int calc(int a,int b,int c,int d){
	if(a==0&&b==0) return vv[c][d];
	if(a==0){
		return vv[c][d]-vv[c][b-1];
	}
	if(b==0){
		return vv[c][d]-vv[a-1][d];
	}
	return vv[c][d]-vv[a-1][d]-vv[c][b-1]+vv[a-1][b-1];
}
pii foo(int a,int b,int c,int d){
	pii ret=pii(1,calc(a,b,c,d));
	if(dp[a][b][c][d].F!=-1) return dp[a][b][c][d];
	reep(i,a,c){
		if(calc(a,b,i,d)>=lim&&calc(i+1,b,c,d)>=lim){
			pii aa=foo(a,b,i,d);
			pii bb=foo(i+1,b,c,d);
			if(ret.F<aa.F+bb.F){
				ret.F=aa.F+bb.F;
				ret.S=min(aa.S,bb.S);
			}
			else if(ret.F==aa.F+bb.F){
				ret.S=max(ret.S,min(aa.S,bb.S));
			}
		}
	}
	reep(i,b,d){
		if(calc(a,b,c,i)>=lim&&calc(a,i+1,c,d)>=lim){
			pii aa=foo(a,b,c,i);
			pii bb=foo(a,i+1,c,d);
			if(ret.F<aa.F+bb.F){
				ret.F=aa.F+bb.F;
				ret.S=min(aa.S,bb.S);
			}
			else if(ret.F==aa.F+bb.F){
				ret.S=max(ret.S,min(aa.S,bb.S));
			}
		}
	}
	// cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<ret.F<<" "<<ret.S-vv[h-1][w-1]<<endl;
	return dp[a][b][c][d]=ret;
}
void mainmain(){
	while(cin>>h>>w>>s,h||w||s){
		rep(i,33){
			rep(j,33){
				rep(k,33){
					rep(l,33){
						dp[i][j][k][l]=pii(-1,0);
					}
				}
			}
		}
		vvint in;
		initvv(in,h,w);
		rep(i,h){
			rep(j,w){
				cin>>in[i][j];
				vv[i][j]=in[i][j];
			}
		}
		reep(i,1,h){
			vv[i][0]+=vv[i-1][0];
		}
		reep(i,1,w){
			vv[0][i]+=vv[0][i-1];
		}
		reep(i,1,h){
			reep(j,1,w){
				vv[i][j]+=vv[i-1][j]+vv[i][j-1]-vv[i-1][j-1];
			}
		}
		lim=vv[h-1][w-1]-s;
		// cout<<lim<<endl;
		pii ans=foo(0,0,h-1,w-1);
		/*
		??°???????????????????????§?????¶?????? ??? ??????????????????1??°?????????????????????????????¨?????????????????°?????????????????????????¨?????????§??? ??? ????????????????¶?????????????????????????
		??°????????????????????????????????°???????????°??????????¨?1, 2????????¶??????????????°???????????????????????§?????§??§???????????°???????????????
		??°??????????????????????¨?1, 2, 3????????¶??????????????°???????????????????????§?????§????????????????????????????????°?????????????????°?????????????????????????????¨?????????????????¨?????§?????¶??????????????§?????????
		*/
		rep(i,h){
			rep(j,w){
				reep(k,i,h){
					reep(l,j,w){
						// cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<dp[i][j][k][l].F<<" "<<dp[i][j][k][l].S-vv[h-1][w-1]<<endl;
					}
				}
			}
		}
		cout<<ans.F<<" "<<-lim+ans.S<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 10508