#include <bits/stdc++.h>
using namespace std;
int imos[201][201];
int sum(int si, int sj, int li, int lj) {
    return imos[li][lj] - imos[li][sj] - imos[si][lj] + imos[si][sj];
}
int sol2(int si, int sj, int li, int lj, int need) {
    if (sum(si, sj, li, lj) / 2 <= need) return 0;
    
    int ret = 0;
    for (int i = si; i < li; ++i) {
        ret = max(ret, min(sum(si, sj, i, lj), sum(i, sj, li, lj)));
    }
    for (int i = sj; i < lj; ++i) {
        ret = max(ret, min(sum(si, sj, li, i), sum(si, i, li, lj)));
    }
    return ret;
}
int sol3(int si, int sj, int li, int lj, int need) {
    if (sum(si, sj, li, lj) / 3 <= need) return 0;
 
    int ret = 0;
    for (int i = si; i < li; ++i) {
        ret = max(ret, min(sum(si, sj, i, lj), sol2(i, sj, li, lj, ret)));
        ret = max(ret, min(sum(i, sj, li, lj), sol2(si, sj, i, lj, ret)));
    }
    for (int i = sj; i < lj; ++i) {
        ret = max(ret, min(sum(si, sj, li, i), sol2(si, i, li, lj, ret)));
        ret = max(ret, min(sum(si, i, li, lj), sol2(si, sj, li, i, ret)));
    }
    return ret;
}
int sol4(int si, int sj, int li, int lj) {
    int ret = 0, s1, s2, s, ini, lim;
    for (int i = si; i < li; ++i) {
        ret = max(ret, min(sum(si, sj, i, lj), sol3(i, sj, li, lj, ret)));
        ret = max(ret, min(sum(i, sj, li, lj), sol3(si, sj, i, lj, ret)));
    }
    for (int i = sj; i < lj; ++i) {
        ret = max(ret, min(sum(si, sj, li, i), sol3(si, i, li, lj, ret)));
        ret = max(ret, min(sum(si, i, li, lj), sol3(si, sj, li, i, ret)));
    }
    for (int i = si; i < li; ++i) {
        for (int j = sj; j < lj; ++j) {
            if (ret >= (s1 = sum(si, sj, i, j))) continue;
            
            for (int k = si; k < li; ++k) {
                if (ret >= (s2 = sum(si, j, k, lj))) continue;
                
                s = min(s1, s2);
                ini = k < i ? j : sj;
                lim = k > i ? j : lj;
                for (int l = ini; l < lim; ++l) {
                    ret = max(ret, min(s, min(sum(i, sj, li, l), sum(k, l, li, lj))));
                }
            }
        }
    }
    return ret;
}
int main(){
    int h, w, n, a[200][200], s;
    cin >> h >> w >> n;
    for (int i = 0; i < h; ++i) {
        s = 0;
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
            s += a[i][j];
            imos[i + 1][j + 1] = imos[i][j + 1] + s;
        }
    }
    switch (n) {
        case 2:
            cout << sol2(0, 0, h, w, 0) << "\n";
            break;
        case 3:
            cout << sol3(0, 0, h, w, 0) << "\n";
            break;
        case 4:
            cout << sol4(0, 0, h, w) << "\n";
            break;
    }
    
    return 0;
}