//templete
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<n;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int N;
    vector<int>A;
    vector<int>B;
    int tmpa,tmpb;
    cin>>N;

    rep(i,N){
        cin>>tmpa>>tmpb;
        A.push_back(tmpa);
        B.push_back(tmpb);
    }

    int time=200009;
    rep(i,N){
        rep(j,N){
            if(i==j)continue;
            if(time>max(A[i],B[j])){
                time=max(A[i],B[j]);
            }
        }
    }
    rep(i,N){
        if(A[i]+B[i]<time){
            time=A[i]+B[i];
        }
    }
    cout<<time;
    return 0;
}
#include <bits/stdc++.h>
#define ALL(a) a.begin(), a.end()
#define ALLR(a) a.rbegin(), a.rend()
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for (int i = (a); i > (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define SI(a) (int)a.size()
using namespace std;
using ll = long long;
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll llceil(ll a, ll b) { return (a + b - 1) / b; }
ll shift(ll a) { return 1LL << a; }
const int INF = shift(30);
const ll LINF = shift(60);

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  REP(i, n) { cin >> a[i] >> b[i]; }

  int ma, mb, ia, ib;
  ma = mb = INF;
  ia = ib = -1;
  REP(i, n) {
    if (chmin(ma, a[i])) {
      ia = i;
    }
    if (chmin(mb, b[i])) {
      ib = i;
    }
  }

  if (ia != ib) {
    cout << max(a[ia], b[ib]) << endl;
  } else {
    int ia2, ib2;
    ia2 = ib2 = -1;
    ma = mb = INF;
    REP(i, n) {
      if (i == ia) continue;
      if (chmin(ma, a[i])) {
        ia2 = i;
      }
      if (chmin(mb, b[i])) {
        ib2 = i;
      }
    }
    cout << min({a[ia] + b[ib], max(a[ia], b[ib2]), max(a[ia2], b[ib])})
         << endl;
  }
}