#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

vector< vector<int> > power,cusum;

int h,w,s,must_cut;

int main(){
    cin >> h >> w >> s;
    while(h>0){
        power=vector< vector<int> >(h+1,vector<int>(w+1,0));
        cusum=vector< vector<int> >(h+1,vector<int>(w+1,0));
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> power.at(i).at(j);
                cusum.at(i).at(j)=power.at(i).at(j)+cusum.at(i-1).at(j)+cusum.at(i).at(j-1)-cusum.at(i-1).at(j-1);
            }
        }
        must_cut=cusum.at(h).at(w)-s;
        vector< vector< vector< vector< pair<int,int> > > > > dp(w+1,vector< vector< vector< pair<int,int> > > >(w+1,vector< vector< pair<int,int> > >(h+1,vector< pair<int,int> >(h+1,make_pair(0,0)))));
        for(int k1=1;k1<=w;k1++){
            for(int i1=0;i1+k1<=w;i1++){
                for(int k2=1;k2<=h;k2++){
                    for(int i2=0;i2+k2<=h;i2++){
                        pair<int,int> cur_p=dp.at(i1).at(i1+k1).at(i2).at(i2+k2);
                        for(int l1=1;l1<k1;l1++){
                            pair<int,int> ref_p=make_pair(dp.at(i1).at(i1+l1).at(i2).at(i2+k2).first+dp.at(i1+l1).at(i1+k1).at(i2).at(i2+k2).first,
                            min(dp.at(i1).at(i1+l1).at(i2).at(i2+k2).second,dp.at(i1+l1).at(i1+k1).at(i2).at(i2+k2).second));
                            if(cur_p.first<ref_p.first){
                                dp.at(i1).at(i1+k1).at(i2).at(i2+k2)=ref_p;
                                cur_p=dp.at(i1).at(i1+k1).at(i2).at(i2+k2);
                            }else if(cur_p.first==ref_p.first){
                                dp.at(i1).at(i1+k1).at(i2).at(i2+k2)=make_pair(cur_p.first,max(cur_p.second,ref_p.second));
                                cur_p=dp.at(i1).at(i1+k1).at(i2).at(i2+k2);
                            }
                        }
                        for(int l2=1;l2<k2;l2++){
                            pair<int,int> ref_p=make_pair(dp.at(i1).at(i1+k1).at(i2).at(i2+l2).first+dp.at(i1).at(i1+k1).at(i2+l2).at(i2+k2).first,
                            min(dp.at(i1).at(i1+k1).at(i2).at(i2+l2).second,dp.at(i1).at(i1+k1).at(i2+l2).at(i2+k2).second));
                            //cout << "cur:" << cur_p.first << " " << cur_p.second << " ref:" << ref_p.first << " " << ref_p.second << endl;
                            if(cur_p.first<ref_p.first){
                                dp.at(i1).at(i1+k1).at(i2).at(i2+k2)=ref_p;
                                cur_p=dp.at(i1).at(i1+k1).at(i2).at(i2+k2);
                            }else if(cur_p.first==ref_p.first){
                                dp.at(i1).at(i1+k1).at(i2).at(i2+k2)=make_pair(cur_p.first,max(cur_p.second,ref_p.second));
                                cur_p=dp.at(i1).at(i1+k1).at(i2).at(i2+k2);
                            }
                        }
                        int allofarea=cusum.at(i2+k2).at(i1+k1)-cusum.at(i2).at(i1+k1)-cusum.at(i2+k2).at(i1)+cusum.at(i2).at(i1);
                        if(allofarea>=must_cut){
                            pair<int,int> ref_p=make_pair(1,allofarea-must_cut);
                            if(cur_p.first<ref_p.first){
                                dp.at(i1).at(i1+k1).at(i2).at(i2+k2)=ref_p;
                                cur_p=dp.at(i1).at(i1+k1).at(i2).at(i2+k2);
                            }else if(cur_p.first==ref_p.first){
                                dp.at(i1).at(i1+k1).at(i2).at(i2+k2)=make_pair(cur_p.first,max(cur_p.second,ref_p.second));
                                cur_p=dp.at(i1).at(i1+k1).at(i2).at(i2+k2);
                            }
                        }
                    }
                }
            }
        }
        /*
        for(int k1=1;k1<=w;k1++){
            for(int i1=0;i1+k1<=w;i1++){
                for(int k2=1;k2<=h;k2++){
                    for(int i2=0;i2+k2<=h;i2++){
                        cout << i1 << " " << k1 << " " << i2 << " " << k2 << " " << endl;
                        cout << dp.at(i1).at(i1+k1).at(i2).at(i2+k2).first << " " << dp.at(i1).at(i1+k1).at(i2).at(i2+k2).second << endl;
                    }
                }
            }
        }
        */
        pair<int,int> ans=dp.at(0).at(w).at(0).at(h);
        cout << ans.first << " " << ans.second << endl;
        cin >> h >> w >> s;
    }
}


Measured memory_bytes: 13700