#include <bits/stdc++.h>
using namespace std;
bool mysort(const pair<int, int> &x, const pair<int, int> &y) {
  if ((x.first < y.first) || (x.first == y.first && x.second < y.second))
    return 1;
  else
    return 0;
}
int main() {
  int n, i, maxi;
  scanf(" %d", &n);
  vector<pair<int, int> > a(n);
  for (i = 0; i < n; i++) {
    scanf(" %d", &(a[i].first)), scanf(" %d", &(a[i].second));
  }
  sort(a.begin(), a.end(), mysort);
  maxi = a[0].second;
  for (i = 1; i < n; i++) {
    if (a[i].second >= maxi)
      maxi = a[i].second;
    else
      maxi = a[i].first;
  }
  cout << maxi << endl;
}
