import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

bool solve() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto S = s[2];
    if (H == 0 || W == 0) return false;
    auto A = H.iota.map!(_ => readln.split.map!(to!int).array).array;

    auto B = new int[][](H+1, W+1);
    foreach (i; 0..H) foreach (j; 0..W) B[i+1][j+1] = A[i][j];
    foreach (i; 0..H+1) foreach (j; 0..W) B[i][j+1] += B[i][j];
    foreach (j; 0..W+1) foreach (i; 0..H) B[i+1][j] += B[i][j];

    int sum(int r1, int c1, int r2, int c2) {
        return B[r2+1][c2+1] - B[r2+1][c1] - B[r1][c2+1] + B[r1][c1];
    }

    int total_cost = B[H][W];

    auto mem = new Tuple!(int, int)[][][][](H, W, H, W);
    foreach (i; 0..H) foreach (j; 0..W) foreach (k; 0..H) mem[i][j][k][] = tuple(-1, -1);

    Tuple!(int, int) solve(int r1, int c1, int r2, int c2) {
        if (mem[r1][c1][r2][c2][0] >= 0) return mem[r1][c1][r2][c2];
        int rest = total_cost - sum(r1, c1, r2, c2);
        if (rest > S) return tuple(-1, -1);

        auto ret = tuple(1, rest);

        foreach (i; r1..r2) {
            auto ret1 = solve(r1, c1, i, c2);
            auto ret2 = solve(i+1, c1, r2, c2);
            if (ret1[0] == -1 || ret2[0] == -1) continue;
            int a = ret1[0] + ret2[0];
            int b = max(ret1[1], ret2[1]);
            if (a > ret[0] || (a == ret[0] && b < ret[1])) {
                ret = tuple(a, b);
            }
        }

        foreach (j; c1..c2) {
            auto ret1 = solve(r1, c1, r2, j);
            auto ret2 = solve(r1, j+1, r2, c2);
            if (ret1[0] == -1 || ret2[0] == -1) continue;
            int a = ret1[0] + ret2[0];
            int b = max(ret1[1], ret2[1]);
            if (a > ret[0] || (a == ret[0] && b < ret[1])) {
                ret = tuple(a, b);
            }
        }

        mem[r1][c1][r2][c2] = ret;
        return ret;
    }

    auto ans = solve(0, 0, H-1, W-1);
    writeln(ans[0], " ", S - ans[1]);

    return true;
}

void main() {
    while (solve) {}
}

