#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } template ostream& operator << (ostream& os, const vector& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w, k; cin >> h >> w >> k; if(k > h + w){ cout << 1'000'000'000 << '\n'; return 0; } k = min(k, h + w); vector dp(h, vector(w, vector(k + 1, -1'000'000'003))); vector A(h, vector(w)); cin >> A; dp[0][0][0] = A[0][0]; if(k >= 1) dp[0][0][1] = 1'000'000'000; for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ for(int i = 0; i <= k; i++){ if(y + 1 < h){ dp[y + 1][x][i] = max(dp[y + 1][x][i], min(dp[y][x][i], A[y + 1][x])); if(i + 1 <= k) dp[y + 1][x][i + 1] = max(dp[y + 1][x][i + 1], dp[y][x][i]); } if(x + 1 < w){ dp[y][x + 1][i] = max(dp[y][x + 1][i], min(dp[y][x][i], A[y][x + 1])); if(i + 1 <= k) dp[y][x + 1][i + 1] = max(dp[y][x + 1][i + 1], dp[y][x][i]); } } } } cout << *max_element(dp[h - 1][w - 1].begin(), dp[h - 1][w - 1].end()) << '\n'; }