#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
#define MAX_SZ 33

int dp_g[MAX_SZ][MAX_SZ][MAX_SZ][MAX_SZ]; // group
int dp_y[MAX_SZ][MAX_SZ][MAX_SZ][MAX_SZ]; // yobi-power
int u[MAX_SZ][MAX_SZ];
int rui[MAX_SZ][MAX_SZ];

class Solve {
public:

    int l_cost; // 最小グループ


    int kukei(int a, int b, int x, int y) {
        a--, b--, x--, y--;
        int ret = rui[x][y];
        if (b >= 0)ret -= rui[x][b];
        if (a >= 0)ret -= rui[a][y];
        if (a >= 0 && b >= 0)ret += rui[a][b];

        return ret;
    }

    pair<int, int> rec(int a, int b, int x, int y) {

        int &ret_g = dp_g[a][b][x][y];
        int &ret_y = dp_y[a][b][x][y];
        if (ret_g != -1) return make_pair(ret_g, ret_y);

        ret_g = 1;
        ret_y = kukei(a, b, x, y);

        for (int i = a + 1; i < x; ++i) {
            // [a, b) -> [a, i) + [i, b)
//            int tmp = rec(a, i, x, y) + rec(i, b, x, y);

            auto A = rec(a, b, i, y);
            auto B = rec(i, b, x, y);
            int tmp_g = A.first + B.first;
            int tmp_y = min(A.second, B.second);

            if (tmp_y < l_cost) {
                continue;
            }
            if (tmp_g > ret_g) {
                ret_g = tmp_g;
                ret_y = tmp_y;
            } else if (tmp_g == ret_g && tmp_y > ret_y) {
                ret_g = tmp_g;
                ret_y = tmp_y;
            }
        }

        for (int i = b + 1; i < y; ++i) {
            auto A = rec(a, b, x, i);
            auto B = rec(a, i, x, y);
            int tmp_g = A.first + B.first;
            int tmp_y = min(A.second, B.second);

            if (tmp_y < l_cost) {
                continue;
            }
            if (tmp_g > ret_g) {
                ret_g = tmp_g;
                ret_y = tmp_y;
            } else if (tmp_g == ret_g && tmp_y > ret_y) {
                ret_g = tmp_g;
                ret_y = tmp_y;
            }

        }


        if (ret_y < l_cost) {
            ret_g = 0;
            ret_y = INF;
            return make_pair(ret_g, ret_y);
        }

        return make_pair(ret_g, ret_y);
//        return ret;
    }

    bool solve() {
        int h, w, s;
        cin >> h >> w >> s;
        if (h == 0) return false;
        memset(dp_g, -1, sizeof(dp_g));
        memset(dp_y, -1, sizeof(dp_y));

        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> u[i][j];
            }
            for (int j = 0; j < w; ++j) {
                if (j == 0) rui[i][j] = u[i][j];
                else rui[i][j] = rui[i][j - 1] + u[i][j];
            }
        }
        for (int j = 0; j < w; ++j) {
            for (int i = 1; i < h; ++i) {
                rui[i][j] += rui[i - 1][j];
            }
        }

        l_cost = kukei(0, 0, h, w) - s;

        auto tapu = rec(0, 0, h, w);
        Int g = tapu.first;
        Int y = tapu.second - l_cost;

        cout << g << " " << y << endl;


//        int ans = rec(0, 0, h, w);


        return true;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    while (Solve().solve());


    return 0;
}



Measured memory_bytes: 12440