#include<bits/stdc++.h>
using namespace std;
int n,a[10005],b[10005],ans=12345678;
int main()
{
	cin>>n;
    for(int i=0;i<n;i++)
    	cin>>a[i]>>b[i];
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            if (i==j)
                ans=min(ans,a[i]+b[i]);
            else
                ans=min(ans,max(a[i],b[j]));
    cout<<ans;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define pb push_back
#define endl '\n'
#define sa(x) sort((x).begin(), (x).end());
#define int long long

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T> static inline void sd(vector<T> &x) {sort((x).begin(), (x).end(), greater<T>()) ; }


void solve(){
	int n;
	cin>>n;
	vector<int> v[2];
	v[0].resize(n);
	v[1].resize(n);

	int a=LLONG_MAX, b=LLONG_MAX;
	rep(i,0,n){
		cin>>v[0][i]>>v[1][i];
		amin(a, v[1][i]+v[0][i]);
		rep(j,0,i){
			amin(a, min(max(v[0][i], v[1][j]), max(v[1][i], v[0][j])));
		}
	}
	
	cout<<a;
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int testcases=1;
	//cin>>testcases;
	while(testcases--){
		solve();
	}
	return 0;	
}
