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

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

int S;
int 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();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

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

int rect(int i1, int j1, int i2, int j2)
{
    return s[i2+1][j2+1] - s[i2+1][j1] - s[i1][j2+1] + s[i1][j1];
}

void rec(int *xx, int *yy, int i1, int j1, int i2, int j2)
{
	int i, j, x, y, x1, y1, x2, y2;

	if (memo[i1][j1][i2][j2][0]) {
		*xx = memo[i1][j1][i2][j2][0], *yy = memo[i1][j1][i2][j2][1]; return;
	}
    
	x = 1, y = S - sum + rect(i1, j1, i2, j2);

	for (j = j1; j < j2; j++) {
		if (S - sum + rect(i1, j1,  i2, j ) < 0) continue;
		if (S - sum + rect(i1, j+1, i2, j2) < 0) continue;
		rec(&x1, &y1, i1, j1 , i2, j );
		rec(&x2, &y2, i1, j+1, i2, j2);
		if (x1+x2 > x) {
			x = x1+x2;
			if (y1 > y2) y1 = y2;
			if (y1 < y ) y  = y1;
		} else if (x1+x2 == x) {
			if (y1 > y2) y1 = y2;
			if (y1 > y ) y  = y1;
		}
    }

	for (i = i1; i < i2; i++) {
		if (S - sum + rect(i1 , j1, i , j2) < 0) continue;
		if (S - sum + rect(i+1, j1, i2, j2) < 0) continue;
		rec(&x1, &y1, i1 , j1, i,  j2);
		rec(&x2, &y2, i+1, j1, i2, j2);
		if (x1+x2 > x) {
			x = x1+x2;
			if (y1 > y2) y1 = y2;
			if (y1 < y ) y  = y1;
		} else if (x1+x2 == x) {
			if (y1 > y2) y1 = y2;
			if (y1 > y ) y  = y1;
		}
	}
	*xx = memo[i1][j1][i2][j2][0] = x, *yy = memo[i1][j1][i2][j2][1] = y;
}

int main(void)
{
	int h, w, t, i, j, ans1, ans2;

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