#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    FOR(i, n) cin >> a[i] >> b[i];

    int sol = 1e9;
    FOR(i, n){
        FOR(j, n){
            if (i == j)
                umin(sol, a[i] + b[j]);
            else
                umin(sol, max(a[i], b[j]));
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <utility>
using ll=long long;
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    int MX=1e6;
    int minA=MX;
    int minB=MX;
    for(int i=0;i<N;i++){
        minA=min(minA,A[i]);
        minB=min(minB,B[i]);
    }
    //cout<<minA<<" "<<minB<<endl;

    int cnta=0;
    int cntb=0;
    int cntab=0;
    for(int i=0;i<N;i++){
        if(A[i]==minA){
            cnta++;
        }
        if(B[i]==minB){
            cntb++;
        }
        if(A[i]==minA && B[i]==minB){
            cntab++;
        }
    }

    int ans=0;
    if(cnta==1 && cntb==1 && cntab==1){
        ans=minA+minB;
        int mmA=MX;
        int mmB=MX;
        for(int i=0;i<N;i++){
            if(A[i]!=minA){
                mmA=min(mmA,A[i]);
                mmB=min(mmB,B[i]);
            }
        }
        ans=min(ans,min(max(mmA,minB),max(minA,mmB)));
    }else{
        ans=max(minA,minB);
    }
    cout<<ans<<endl;

    return 0;
}