#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A, B;
  vector<int> vec_a;
  vector<int> vec_b;
  for(int i = 0; i < N; i++) {
    cin >> A >> B;
    vec_a.push_back(A);
    vec_b.push_back(B);
  }
 
  vector<int>::iterator a_iter = min_element(vec_a.begin(), vec_a.end());
  size_t a_index = distance(vec_a.begin(), a_iter);
 
  vector<int>::iterator b_iter = min_element(vec_b.begin(), vec_b.end());
  size_t b_index = distance(vec_b.begin(), b_iter);
 
  if(a_index != b_index) {
    if(*a_iter > *b_iter) {
      cout << *a_iter << endl;
      return 0;
    } else {
      cout << *b_iter << endl;
      return 0;
    }
  } else {
    int ans = *a_iter + *b_iter;
    int _a = *a_iter;
    int _b = *b_iter;
    sort(vec_a.begin(), vec_a.end());
    if (ans > max(vec_a[1], _b)) {
      ans = max(vec_a[1], _b);
    }
    sort(vec_b.begin(), vec_b.end());
    if (ans > max(vec_b[1], _a)) {
      ans = max(vec_b[1], _a);
    }
    cout << ans << endl;
    return 0;
  }
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long int;
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> T(N);
  rep(i, N) cin >> T[i].first >> T[i].second;

  int ans = INT_MAX;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        chmin(ans, T[i].first + T[i].second);
      } else {
        chmin(ans, max(T[i].first, T[j].second));
      }
    }
  }
  cout << ans << endl;
}