class Array
	def accum
		ac = Array.new(size + 1)
		ac[0] = 0
		(1..size).each do |i|
			ac[i] = ac[i-1] + self[i-1]
		end
		ac
	end

	def accum!
		(1..size-1).each{|i|
			self[i] += self[i-1]
		}
		self.unshift(0)
	end

	def accum_2d
		ac = map{|r| r.accum}
		(1..size-1).each{|i|
			(1..ac[0].size-1).each{|j|
				ac[i][j] += ac[i-1][j]
			}
		}
		ac.unshift([0] * ac[0].size)
		ac
	end

	def accum_2d!
		each{|r| r.accum!}
		(1..size-1).each{|i|
			(1..self[0].size-1).each{|j|
				self[i][j] += self[i-1][j]
			}
		}
		unshift([0] * self[0].size)
	end
end

def compute(y1, y2, x1, x2)
	$accum[y2][x2] - $accum[y1-1][x2] - $accum[y2][x1-1] + $accum[y1-1][x1-1]
end

def encode(y1, y2, x1, x2)
	(y1 << 18) + (y2 << 12) + (x1 << 6) + x2
end

def decode(code)
	y1 = (code >> 18) & 0b111111
	y2 = (code >> 12) & 0b111111
	x1 = (code >> 6) & 0b111111
	x2 = (code >> 0) & 0b111111
	return [y1, y2, x1, x2]
end

def b_split(code)
	y1, y2, x1, x2 = decode(code)
	cache = $b_memo[code]
	return cache if cache
	k, save = 1, compute(y1, y2, x1, x2)
	return $b_memo[code] = nil if save < $min_save
	return $b_memo[code] = [k, save] if y1 == y2 && x1 == x2

	(y1..y2-1).each do |y|
		k1, s1 = v_split(encode(y1, y, x1, x2)) || next
		k2, s2 = b_split(encode(y+1, y2, x1, x2)) || break
		k3 = k1 + k2
		s3 = (s1 < s2 ? s1 : s2)
		if k3 > k
			k, save = k3, s3
		elsif k3 == k
			save = s3 if s3 > save
		end
	end

	(x1..x2-1).each do |x|
		k1, s1 = h_split(encode(y1, y2, x1, x)) || next
		k2, s2 = b_split(encode(y1, y2, x+1, x2)) || break
		k3 = k1 + k2
		s3 = (s1 < s2 ? s1 : s2)
		if k3 > k
			k, save = k3, s3
		elsif k3 == k
			save = s3 if s3 > save
		end
	end

	$b_memo[code] = [k, save]
end

def v_split(code)
	y1, y2, x1, x2 = decode(code)
	cache = $v_memo[code]
	return cache if cache
	k, save = 1, compute(y1, y2, x1, x2)
	return $v_memo[code] = nil if save < $min_save
	return $v_memo[code] = [k, save] if y1 == y2 && x1 == x2

	(x1..x2-1).each do |x|
		k1, s1 = h_split(encode(y1, y2, x1, x)) || next
		k2, s2 = b_split(encode(y1, y2, x+1, x2)) || break
		k3 = k1 + k2
		s3 = (s1 < s2 ? s1 : s2)
		if k3 > k
			k, save = k3, s3
		elsif k3 == k
			save = s3 if s3 > save
		end
	end

	$v_memo[code] = [k, save]
end

def h_split(code)
	y1, y2, x1, x2 = decode(code)
	cache = $h_memo[code]
	return cache if cache
	k, save = 1, compute(y1, y2, x1, x2)
	return $h_memo[code] = nil if save < $min_save
	return $h_memo[code] = [k, save] if y1 == y2 && x1 == x2

	(y1..y2-1).each do |y|
		k1, s1 = v_split(encode(y1, y, x1, x2)) || next
		k2, s2 = b_split(encode(y+1, y2, x1, x2)) || break
		k3 = k1 + k2
		s3 = (s1 < s2 ? s1 : s2)
		if k3 > k
			k, save = k3, s3
		elsif k3 == k
			save = s3 if s3 > save
		end
	end
	$h_memo[code] = [k, save]
end

loop do
	h, w, s = gets.split.map(&:to_i)
	break if h == 0
	a = (1..h).map { gets.split.map(&:to_i) }
	$accum = a.accum_2d
	d = $accum[h][w]
	$min_save = d - s
	
	$b_memo = Hash.new
	$h_memo = Hash.new
	$v_memo = Hash.new
	k, min_save = b_split(encode(1, h, 1, w))	
	
	
	printf("%d %d\n", k, s - (d - min_save))
end