#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, i, x, y;
  cin >> n;
  vector<pair<long, long>> v;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end());
  for (i = 1; i < n; i++) {
    if (v[i].second < v[i - 1].second) {
      v[i].second = v[i].first;
    }
  }
  cout << v[n - 1].second;
}
