#include <bits/stdc++.h>

using namespace std;

struct Score {
    Score() = default;
    Score(int g, int p) : group{g}, preparation{p} {}
    bool operator<(const Score& s) const
    {
        if (group < s.group) {
            return true;
        } else if (s.group < group) {
            return false;
        }
        if (preparation < s.preparation) {
            return true;
        }
        return false;
    }
    Score operator+(const Score& s) const
    {
        return Score{group + s.group, min(preparation, s.preparation)};
    }
    int group;
    int preparation;
};

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>> need(h, vector<int>(w));
        vector<vector<int>> sum(h, vector<int>(w, 0));
        vector<vector<vector<vector<Score>>>> dp(h + 1, vector<vector<vector<Score>>>(h + 1, vector<vector<Score>>(w + 1, vector<Score>(w + 1, Score{0, 0}))));
        int needsum = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> need[i][j];
                needsum += need[i][j];
                if (i == 0 and j == 0) {
                    sum[i][j] = need[i][j];
                } else if (i == 0) {
                    sum[i][j] = sum[i][j - 1] + need[i][j];
                } else if (j == 0) {
                    sum[i][j] = sum[i - 1][j] + need[i][j];
                } else {
                    sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + need[i][j];
                }
            }
        }

        const int necessary = needsum - s;
        for (int lint = 1; lint <= h; lint++) {
            for (int rint = 1; rint <= w; rint++) {
                for (int l1 = 0; l1 <= h - lint; l1++) {
                    for (int r1 = 0; r1 <= w - rint; r1++) {
                        const int l2 = l1 + lint;
                        const int r2 = r1 + rint;
                        Score maxscore = Score{0, numeric_limits<int>::min()};
                        int needsum = sum[l2 - 1][r2 - 1];
                        if (l1 > 0) {
                            needsum -= sum[l1 - 1][r2 - 1];
                        }
                        if (r1 > 0) {
                            needsum -= sum[l2 - 1][r1 - 1];
                        }
                        if (r1 > 0 and l1 > 0) {
                            needsum += sum[l1 - 1][r1 - 1];
                        }
                        if (needsum >= necessary) {
                            maxscore.group = 1;
                            maxscore.preparation = needsum - necessary;
                        } else {
                            maxscore.group = 0;
                            maxscore.preparation = necessary - needsum;
                        }

                        for (int l = l1 + 1; l < l2; l++) {
                            const Score s1 = dp[l1][l][r1][r2];
                            const Score s2 = dp[l][l2][r1][r2];
                            const Score s = s1 + s2;
                            if (maxscore < s) {
                                maxscore = s;
                            }
                        }
                        for (int r = r1 + 1; r < r2; r++) {
                            const Score s1 = dp[l1][l2][r1][r];
                            const Score s2 = dp[l1][l2][r][r2];
                            const Score s = s1 + s2;
                            if (maxscore < s) {
                                maxscore = s;
                            }
                        }
                        dp[l1][l2][r1][r2] = maxscore;
                        // cout << "l1: " << l1 << " l2: " << l2 << " r1: " << r1 << " r2: " << r2 << endl;
                        // cout << dp[l1][l2][r1][r2].group << " " << dp[l1][l2][r1][r2].preparation << endl;
                    }
                }
            }
        }
        const Score ans = dp[0][h][0][w];
        cout << ans.group << " " << ans.preparation << endl;
    }

    return 0;
}

Measured memory_bytes: 13704