#include <bits/stdc++.h>
using namespace std;
void OJ() {}
int solve() {
  int n, m;
  cin >> n >> m;
  int c[n][m];
  int mx = 0, mn = INT_MAX, t = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      cin >> c[i][j];
    }
    if (*max_element(c[i], c[i] + m) >= mx) {
      mx = *max_element(c[i], c[i] + m);
      mn = *min_element(c[i], c[i] + m);
    } else {
      if (*min_element(c[i], c[i] + m) > mn) mn = *min_element(c[i], c[i] + m);
    }
    t = max(mn, t);
  }
  cout << t;
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  solve(), cout << endl;
  return 0;
}
