#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using p = pair<int, int>;

int main() {
    //vector<vector<int>>data(h,vector<int>(w));

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    int am = 100000, bm = 100000, ai = 0, bi = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < am) {
            am = a[i];
            ai = i;
        }
        if (b[i] < bm) {
            bm = b[i];
            bi = i;
        }
    }
    int counta = 0, countb = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == am) {
            counta++;
        }
        if (b[i] == bm) {
            countb++;
        }
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int c = min(a[1], b[1]);

    if (ai != bi) {
        cout << max(am, bm) << endl;
        return 0;
    } else if (ai == bi && (counta > 1 || countb > 1)) {
        cout << max(am, bm) << endl;
        return 0;
    } else {
        cout << min(c, am + bm) << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N], b[N];
int n, m;
int main(){
	scanf("%d",&n);
	int ans = 2e9;
	for(int i=0; i<n; ++i){
		scanf("%d%d",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<<endl;
}