#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集
int h, w, s;
int a[35][35];
int sum[35][35];

pair<int, int> dp[35][35][35][35];
int t = 0;

int calc(int y1, int x1, int y2, int x2){
  return sum[y2+1][x2+1] - sum[y2+1][x1] - sum[y1][x2+1] + sum[y1][x1];
}

pair<int, int> rec(int y1, int x1, int y2, int x2){

  if(dp[y1][x1][y2][x2] != make_pair(0, INT_MAX)) return dp[y1][x1][y2][x2];

  pair<int, int> res = make_pair(1, s - (t - calc(y1, x1, y2, x2)));

  /* 分割を全て試す */
  for(int i=x1; i<x2; i++){
    if(s - (t - calc(y1, x1, y2, i)) < 0) continue;
    if(s - (t - calc(y1, i+1, y2, x2)) < 0) continue;

    pair<int, int> res1 = rec(y1, x1, y2, i);
    pair<int, int> res2 = rec(y1, i+1, y2, x2);

    chmax(res, make_pair(res1.first + res2.first, min(res1.second, res2.second)));
  }

  for(int i=y1; i<y2; i++){
    if(s - (t - calc(y1, x1, i, x2)) < 0) continue;
    if(s - (t - calc(i+1, x1, y2, x2)) < 0) continue;

    pair<int, int> res1 = rec(y1, x1, i, x2);
    pair<int, int> res2 = rec(i+1, x1, y2, x2);

    chmax(res, make_pair(res1.first + res2.first, min(res1.second, res2.second)));
  }

  return dp[y1][x1][y2][x2] = res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  
  while(cin >> h >> w >> s){
    if(h == 0 && w == 0 && s == 0) break;
    memset(a, 0, sizeof(a));
    memset(sum, 0, sizeof(sum));
    t = 0;
    REP(i,h){
      REP(j,w){
        cin >> a[i][j];
        t += a[i][j];
      }
    }

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        sum[i+1][j+1] = a[i][j];
      }
    }
    for(int i=0; i<=h; i++){
      for(int j=0; j<w; j++){
        sum[i][j+1] += sum[i][j];
      }
    }
    for(int j=0; j<=w; j++){
      for(int i=0; i<h; i++){
        sum[i+1][j] += sum[i][j];
      }
    }

    REP(i,35) REP(j,35)REP(k,35)REP(l,35) dp[i][j][k][l] = make_pair(0, INT_MAX);
    auto ans = rec(0, 0, h-1, w-1);

    cout << ans.first << " " << ans.second << endl;
  }
  return 0;
}



Measured memory_bytes: 14880