#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

P dp[32][32][32][32];
int score0[32][32];
int score[32][32][32][32];
int field[32][32];

int main(){
  int h, w, s;
  while(cin >> h >> w >> s && (h || w || s)){
    
    memset(score, 0, sizeof(score));
    memset(score0, 0, sizeof(score0));
    
    int sum = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
		cin >> field[i][j];
		if(i != 0){
		  score0[i][j] += score0[i-1][j];
		}
		if(j != 0){
		  score0[i][j] += score0[i][j-1];
		}
		if(i != 0 && j != 0){
		  score0[i][j] -= score0[i-1][j-1];
		}
		score0[i][j] += field[i][j];
		sum += field[i][j];
		
	  }

    }

	sum -= s;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			for(int k = 0; k <= i; k++){
				for(int l = 0; l <= j; l++){
					if(k == 0 && l == 0){
						score[k][i][l][j] = score0[i][j];
					}else if(k == 0 && l != 0){
						score[k][i][l][j] = score0[i][j] - score0[i][l-1];
					}else if(k != 0 && l == 0){
						score[k][i][l][j] = score0[i][j] - score0[k-1][j];
				    }else{
			      score[k][i][l][j] = score0[i][j] - score0[i][l-1] 
					- score0[k-1][j] + score0[k-1][l-1];
					}
				}
			}
		}
    }
	
	fill(&dp[0][0][0][0], &dp[31][31][31][31]+1, P(0, 0));
    for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			for(int k = 0; k + i <= h; k++){
				for(int l = 0; l + j <= w; l++){
					bool f = false;
					for(int m = k + 1; m < k + i; m++){
						if(score[k][m-1][l][l+j-1] >= sum &&  score[m][k+i-1][l][l+j-1] >= sum){
							f = true;
							int num = dp[k][m-k][l][j].first + dp[m][i-(m-k)][l][j].first;
							int pow = min(dp[k][m-k][l][j].second,dp[m][i-(m-k)][l][j].second);
							if(dp[k][i][l][j].first < num || dp[k][i][l][j].first == num && dp[k][i][l][j].second < pow){
								dp[k][i][l][j].first = num;
								dp[k][i][l][j].second = pow;
							}
						}
					}
					for(int m = l + 1; m < l + j; m++){
						if(score[k][k+i-1][l][m-1] >= sum &&  score[k][k+i-1][m][l+j-1] >= sum){
							f = true;
							int num = dp[k][i][l][m-l].first + dp[k][i][m][j-(m-l)].first;
							int pow = min(dp[k][i][l][m-l].second, dp[k][i][m][j-(m-l)].second);
							if(dp[k][i][l][j].first < num || dp[k][i][l][j].first == num && dp[k][i][l][j].second < pow){
								dp[k][i][l][j].first = num;
								dp[k][i][l][j].second = pow;
							}
						
						}
					}
					if(!f){
						dp[k][i][l][j].first = 1;
						dp[k][i][l][j].second = score[k][k+i-1][l][l+j-1];
					}
				}
			}
		}
	}
    cout << dp[0][h][0][w].first << " " << dp[0][h][0][w].second - sum << endl;
    
  }
    
    
  return 0;
}

Measured memory_bytes: 0