// AOJ 1176: Planning Rolling Blackouts
// 2018.1.9 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int S, sum;
int u[34][34], s[34][34];
int memo[34][34][34][34][2];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
//	while (c < '0') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void calc(int h, int w)
{
	int r, c;
	memset(s, 0, sizeof(s));
	for (r = 0; r <  h; r++) for (c = 0; c <  w; c++) s[r+1][c+1]  = u[r][c];
	for (r = 0; r <= h; r++) for (c = 0; c <  w; c++) s[r  ][c+1] += s[r][c];
	for (r = 0; r <  h; r++) for (c = 0; c <= w; c++) s[r+1][c  ] += s[r][c];
}

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

void rec(int *xx, int *yy, int r1, int c1, int r2, int c2)
{
	int r, c, x, y, x1, y1, x2, y2;

	if (memo[r1][c1][r2][c2][0]) {
		*xx = memo[r1][c1][r2][c2][0], *yy = memo[r1][c1][r2][c2][1]; return;
	}
    
	x = 1, y = S - sum + rect(r1, c1, r2, c2);

	for (r = r1; r < r2; r++) {
		if (S - sum + rect(r1 , c1, r , c2) < 0) continue;
		if (S - sum + rect(r+1, c1, r2, c2) < 0) continue;
		rec(&x1, &y1, r1 , c1, r,  c2);
		rec(&x2, &y2, r+1, c1, r2, c2);
		if (x < x1+x2) {
			x = x1+x2;
			if (y1 > y2) y1 = y2;
			if (y  > y1) y  = y1;
		} else if (x == x1+x2) {
			if (y1 > y2) y1 = y2;
			if (y  < y1) y  = y1;
		}
	}
	for (c = c1; c < c2; c++) {
		if (S - sum + rect(r1, c1,  r2, c ) < 0) continue;
		if (S - sum + rect(r1, c+1, r2, c2) < 0) continue;
		rec(&x1, &y1, r1, c1 , r2, c );
		rec(&x2, &y2, r1, c+1, r2, c2);
		if (x < x1+x2) {
			x = x1+x2;
			if (y1 > y2) y1 = y2;
			if (y  > y1) y  = y1;
		} else if (x == x1+x2) {
			if (y1 > y2) y1 = y2;
			if (y  < y1) y  = y1;
		}
    }

	*xx = memo[r1][c1][r2][c2][0] = x, *yy = memo[r1][c1][r2][c2][1] = y;
}

int main(void)
{
	int h, w, r, c, ans1, ans2;

	while (h = in()) {
		w = in(), S = in();
		sum = 0; for (r = 0; r < h; r++) for (c = 0; c < w; c++) sum += u[r][c] = in();
		memset(memo, 0, sizeof(memo));
        calc(h, w);
        rec(&ans1, &ans2, 0, 0, h - 1, w - 1);
        printf("%d %d\n", ans1, ans2);
    }
    return 0;
}
