### subroutines

def rect(x, y, w, h)
  #p ['rect', x, y, w, h]
  $sums[y + h][x + w] - $sums[y + h][x] - $sums[y][x + w] + $sums[y][x]
end

def count_div(x0, y0, w, h, ar = rect(x0, y0, w, h))
  return $cache[y0][x0][h][w] if ! $cache[y0][x0][h][w].nil?

  min_s = ar
  max_gn = 1

  for dy in (1...h)
    ar0 = rect(x0, y0, w, dy)
    next if ar0 < $limit
    ar1 = rect(x0, y0 + dy, w, h - dy)
    next if ar1 < $limit

    gn0, s0 = count_div(x0, y0, w, dy, ar0)
    gn1, s1 = count_div(x0, y0 + dy, w, h - dy, ar1)

    gn = gn0 + gn1
    s = (s0 < s1) ? s0 : s1

    if max_gn < gn || (max_gn == gn && min_s < s)
      max_gn = gn
      min_s = s
    end    
  end

  for dx in (1...w)
    ar0 = rect(x0, y0, dx, h)
    next if ar0 < $limit
    ar1 = rect(x0 + dx, y0, w - dx, h)
    next if ar1 < $limit

    gn0, s0 = count_div(x0, y0, dx, h, ar0)
    gn1, s1 = count_div(x0 + dx, y0, w - dx, h, ar1)

    gn = gn0 + gn1
    s = (s0 < s1) ? s0 : s1

    if max_gn < gn || (max_gn == gn && min_s < s)
      max_gn = gn
      min_s = s
    end    
  end

  $cache[y0][x0][h][w] = [max_gn, min_s]
end

### main

loop do
  h, w, sup = gets.split.map(&:to_i)
  break if (h | w | sup) == 0

  $dms = h.times.map{gets.split.map(&:to_i)}

  $sums = (h + 1).times.map{(w + 1).times.map{0}}
  for y in (0...h)
    for x in (0...w)
      $sums[y + 1][x + 1] =
        $dms[y][x] + $sums[y + 1][x] + $sums[y][x + 1] - $sums[y][x]
    end
  end
  #p $sums; exit

  $limit = $sums[h][w] - sup
  #p $limit
  
  $cache = h.times.map{w.times.map{(h + 1).times.map{(w + 1).times.map{nil}}}}

  max_gn, min_s = count_div(0, 0, w, h)
  puts [max_gn, min_s - $limit].join(' ')
end