#include<iostream>

using namespace std;

int main()
{
    int n,a,b,miA,miB,ans,tmp;
    cin>>n;
    cin>>a>>b;
    miA=a;miB=b;ans=a+b;
    for(int i=1;i<n;i++)
    {
        cin>>a>>b;
        ans=min(ans,a+b);
        tmp=min((max(miA,b)),(max(miB,a)));
        ans=min(ans,tmp);
        miA=min(miA,a);
        miB=min(miB,b);
    }
    cout<<ans<<endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define   fi(a,b) for(int i=a;i<b;i++)
#define   fj(a,b) for(int j=a;j<b;j++)
#define   ff first
#define   ss second
#define   ll long long
#define   ld long double
#define   ull unsigned long long
#define   bp(x) __builtin_popcount(x)
#define   pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define   getMax(x) max_element(x.begin(),x.end())
#define   getMin(x) min_element(x.begin(),x.end())
#define   endl "\n"
typedef   vector<int> vi;
typedef   vector< pair<int,int> > vii;
typedef   vector<long long> vl;
typedef   pair<int,int> pii;
typedef   pair<ll,ll> pll;
typedef   vector< pair<ll,ll> > vll;
//int dx[]={1,0,-1,0};
//int dy[]={0,1,0,-1};
//int dx[]={-1,0,1,1,1,0,-1,-1};
//int dy[]={-1,-1,-1,0,1,1,1,0};

void nikal_pehli_fursat_mai(){
    ll n;
    cin>>n;
    vl a(n), b(n);
    ll ans = 1e18;
    fi(0, n){
        cin>>a[i]>>b[i];
    }
    fi(0, n){
        fj(0, n){
            if(i==j) {
                ans = min(ans, a[i]+b[j]);
            }
            else {
                // cout<<a[i]<<" "<<i<<" "<<b[j]<<" "<<j<<endl;
                ans = min(ans, max(a[i], b[j]));
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc=1; 
    // cin>>tc;
    while(tc--){
    nikal_pehli_fursat_mai();
    }
}
