// compile in C++11. use -std=c++11.
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// these require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x) << " " 
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef complex<double> point;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& vec){
    os << "[";
    for(const auto& v : vec){
        os << v << ",";
    }
    os << "]";
    return os;
}

pair<int,int> none = make_pair(-1,-1);
pair<int,int> didnotsolve = make_pair(-2,-2);
// group,yobi
pair<int,int> solve(int lx,int uy,int rx,int dy,int s,vector<vector<vector<vector<pair<int,int>>>>>& memo,
                                                    const vector<vector<vector<vector<int>>>>& sum){
    if(memo[lx][uy][rx][dy] != didnotsolve){
        return memo[lx][uy][rx][dy];
    }
    pair<int,int> ret = none;
    int allsum = sum.front().front().back().back();
    if(allsum - sum[lx][uy][rx][dy] > s){
    }else{
        ret = make_pair(1,(s-(allsum-sum[lx][uy][rx][dy])));
    }
    // horiz
    for(int i=0;i<(dy-uy);i++){
        pair<int,int> upper = solve(lx,uy,    rx,uy+i,s,memo,sum);
        pair<int,int> lower = solve(lx,uy+i+1,rx,dy  ,s,memo,sum);
        if(upper == none or lower == none) continue;
        pair<int,int> here = make_pair(upper.first+lower.first,min(upper.second,lower.second));
        ret = max(ret,here);
    }
    // vert
    for(int i=0;i<(rx-lx);i++){
        pair<int,int> upper = solve(lx    ,uy,lx+i,dy,s,memo,sum);
        pair<int,int> lower = solve(lx+i+1,uy,rx  ,dy,s,memo,sum);
        if(upper == none or lower == none) continue;
        pair<int,int> here = make_pair(upper.first+lower.first,min(upper.second,lower.second));
        ret = max(ret,here);
    }
    return memo[lx][uy][rx][dy] = ret;
}

// ret[i][j] = sum of all field in [0,i) x [0,j).
template<typename T>
vector<vector<T>> calc_sum(const vector<vector<T>>& field){
    int h = field.size();
    int w = field[0].size();
    vector<vector<T>> ret(h+1,vector<T>(w+1));
    for(int y=1;y<=h;y++){
        for(int x=0;x<w;x++){
            ret[y][x+1] = ret[y][x] + field[y-1][x];
        }
    }
    for(int x=0;x<w+1;x++){
        for(int y=0;y<h;y++){
            ret[y+1][x] = ret[y+1][x] + ret[y][x];
        }
    }
    return ret;
}
pair<int,int> doit(vector<vector<int>> field,int s){
    int w = field[0].size();
    int h = field.size();
    vector<vector<vector<vector<pair<int,int>>>>> memo(w,vector<vector<vector<pair<int,int>>>>
                                                      (h,vector<vector<pair<int,int>>>
                                                      (w,vector<pair<int,int>>(h,didnotsolve))));
    vector<vector<int>> sum = calc_sum(field);
    vector<vector<vector<vector<int>>>> sum_memo(w,vector<vector<vector<int>>>
                                                (h,vector<vector<int>>
                                                (w,vector<int>(h,0))));

    for(int uy=0;uy<h;uy++){
        for(int dy=uy;dy<h;dy++){
            for(int lx=0;lx<w;lx++){
                for(int rx=lx;rx<w;rx++){
                    sum_memo[lx][uy][rx][dy] = sum[dy+1][rx+1] - sum[uy][rx+1] - sum[dy+1][lx] + sum[uy][lx];
                }
            }
        }
    }
    pair<int,int> ret = solve(0,0,w-1,h-1,s,memo,sum_memo);
    return ret;
}

int main(){
    while(true){
        int h,w,s;
        cin >> h >> w >> s;
        if(h == 0 and w == 0 and s == 0) break;
        vector<vector<int>> field(h,vector<int>(w));
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> field[i][j];
            }
        }
        pair<int,int> ret = doit(field,s);
        cout << ret.first << " " << ret.second << endl;
    }
    return 0;
}

Measured memory_bytes: 16304