#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using db = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define F0R(i, n) FOR(i, 0, n)
#define ROF(i, a, n) for(int i=(n)-1;i>=(a);--i)

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//const ll MOD = 1000000007;
//const ll INF = LLONG_MAX;
//const ld PI = 3.14159265358979323846;

void solve() {
    int n;
    cin >> n;
    pl a[n], b[n];
    F0R(i, n) {
        cin >> a[i].fi;
        a[i].se = i;
        cin >> b[i].fi;
        b[i].se = i;
    }
    sort (a, a + n);
    sort (b, b + n);
    if (a[0].se == b[0].se)
        cout << min({ max(a[0].fi, b[1].fi), max(b[0].fi, a[1].fi), (a[0].fi + b[0].fi) });
    else
        cout << max(a[0].fi, b[0].fi);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tc = 1;
    //cin >> tc;
    while (tc--)
        solve();
}
#include <bits/stdc++.h>
using namespace std;

int n;
int ans = INT_MAX;
int main()
{
  cin >> n;
  vector<int> wa(n);
  vector<int> wb(n);
  for (int i = 0; i < n; i++)
  {
    int a, b;
    cin >> a >> b;
    wa.at(i) = a;
    wb.at(i) = b;
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (i == j)
      {
        ans = min(ans, wa.at(i) + wb.at(j));
      }
      else
      {
        ans = min(ans, max(wa.at(i), wb.at(j)));
      }
    }
  }
  cout << ans << endl;
}