#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { int N, M, K; cin >> N >> M >> K; vector> A(N, vector(M)); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cin >> A[i][j]; } } const int inf = 1e9; vector>> dp(N, vector>(M, vector(min(K, N + M) + 1, -inf))); dp[0][0][0] = A[0][0]; dp[0][0][1] = inf; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { for (int k = 0; k <= min(K, N + M); k++) { if (i + 1 < N) { dp[i + 1][j][k] = max(dp[i + 1][j][k], min(dp[i][j][k], A[i + 1][j])); if (k < min(K, N + M)) dp[i + 1][j][k + 1] = max(dp[i + 1][j][k + 1], dp[i][j][k]); } if (j + 1 < M) { dp[i][j + 1][k] = max(dp[i][j][k], min(dp[i][j][k], A[i][j + 1])); if (k < min(K, N + M)) dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k]); } } } } cout << ranges::max(dp.back().back()) << endl; }