#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, ans = INF;
    cin >> n;
    vector<int> a(n), b(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, max(a[i], b[j]));
            }else{
                ans = min(ans, a[i] + b[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
#define lli long long int
#define sz 10000010
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define in(x) scanf("%lld",&x)
#define ins(x) scanf("%s",x)
#define out(x) printf("%lld",x)
#define outs(x) printf("%s",x)
#define loop(x) for(lli i=0;i<x;i++)
#define loop2(x) for(lli j=0;j<x;j++)
#define eps 0.000000001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define C 0.57721566490153286060651209s
using namespace std;
void solve()
{
	
	lli n;
	cin >> n;
	vector <pair<lli,lli>> a(n),b(n);
	loop(n)
	{
		lli x,y;
		cin >> x >> y;
		a[i] = {x,i+1};
		b[i] = {y,i+1};
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	if(a[0].second!=b[0].second) cout << max(a[0].first,b[0].first) << endl;
	else if(n>=2) cout << min((a[0].first+b[0].first),min(max(a[0].first,b[1].first),max(a[1].first,b[0].first))) << endl;
	else cout << a[0].first+b[0].first << endl;
	return;
}
int main()
{
   fast;
   lli t;
   t=1;
   while(t--)
   	solve();
   return 0;
}
