#include <iostream>
#include <algorithm>

int main() {
    int n;
    int a[1001], b[1001];
    std::cin >> n;
    for(int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i];
    }
    int min = 1000000;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int sum = std::max(a[i], b[j]);
            if (sum < min) min = sum;
            sum = std::max(b[i], a[j]);
            if (sum < min) min = sum;
        }
    }
    for (int i = 0; i < n; ++i) {
        int sum = a[i] + b[i];
        if (sum < min) min = sum;
    }
    std::cout << min << std::endl;
    return 0;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

struct mount{string name; int height;};

int main()
{
    int n;
    cin >> n;
    mount m[n];
    rep(i, n) cin >> m[i].name >> m[i].height;

    int a1 = 0, a2 = -1, m1 = 0, m2 = 0;

    rep(i, n){
        if(m[i].height > m1){
            m2 = m1;
            m1 = m[i].height;
            a2 = a1;
            a1 = i;
        }
        else if(m[i].height > m2){
            m2 = m[i].height;
            a2 = i;
        }
    }

    cout << m[a2].name << endl;

    return 0;
}