#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int area_demand(const std::vector<std::vector<int>>& state, const int left, const int right, const int bottom, const int top) {
	return state[top][right] - state[top][left - 1] - state[bottom - 1][right] + state[bottom - 1][left - 1];
}
std::pair<int, int> cal_max(std::vector<std::vector<int>>& state, const int min_limit, const int left, const int right, const int bottom, const int top, std::vector<std::vector<std::vector<std::vector<std::pair<int, int>>>>> &memo) {
	if (memo[left][right - left][bottom][top - bottom].first > 0) return memo[left][right - left][bottom][top - bottom];
	int max_count = 1;
	int min_demand = area_demand(state, left, right, bottom, top);
	for (auto v = left; v < right; ++v) if (area_demand(state, left, v, bottom, top) >= min_limit && area_demand(state, v + 1, right, bottom, top) >= min_limit) {
		auto l = cal_max(state, min_limit, left, v, bottom, top, memo);
		auto r = cal_max(state, min_limit, v + 1, right, bottom, top, memo);
		if (l.first + r.first > max_count) {
			max_count = l.first + r.first;
			min_demand = std::min(l.second, r.second);
		}
		else if (l.first + r.first == max_count) {
			min_demand = std::max(min_demand, std::min(l.second, r.second));
		}
	}
	for (auto h = bottom; h < top; ++h) if (area_demand(state, left, right, bottom, h) >= min_limit && area_demand(state, left, right, h + 1, top) >= min_limit) {
		auto b = cal_max(state, min_limit, left, right, bottom, h, memo);
		auto t = cal_max(state, min_limit, left, right, h + 1, top, memo);
		if (b.first + t.first > max_count) {
			max_count = b.first + t.first;
			min_demand = std::min(b.second, t.second);
		}
		else if (b.first + t.first == max_count) {
			min_demand = std::max(min_demand, std::min(b.second, t.second));
		}
	}
	return memo[left][right - left][bottom][top - bottom] = std::make_pair(max_count, min_demand);
}
int main(){
	std::vector<std::vector<std::vector<std::vector<std::pair<int, int>>>>> memo(33, std::vector<std::vector<std::vector<std::pair<int, int>>>>(33, std::vector<std::vector<std::pair<int, int>>>(33, std::vector<std::pair<int, int>>(33))));
	while (true) {
		int h, w, s; std::cin >> h >> w >> s; if (h == 0) break;
		std::vector<std::vector<int>> state(h + 1, std::vector<int>(w + 1, 0));
		for (auto i = 1; i <= h; ++i) for (auto j = 1; j <= w; ++j) {
			std::cin >> state[i][j];
			state[i][j] += state[i - 1][j] + state[i][j - 1] - state[i - 1][j - 1];
		}
		for (auto left = 1; left <= w; ++left) {
			for (auto right = left; right <= w; ++right) {
				for (auto bottom = 1; bottom <= h; ++bottom) {
					std::fill(memo[left][right - left][bottom].begin(), memo[left][right - left][bottom].end(), std::make_pair(0, 0));
				}
			}
		}
		auto res = cal_max(state, state.back().back() - s, 1, w, 1, h, memo);
		std::cout << res.first << ' ' << s + res.second - state.back().back() << '\n';
	}
}


Measured memory_bytes: 13612