#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  pair<long long, long long> p[n];
  long long x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    p[i].first = x;
    p[i].second = y;
  }
  sort(p, p + n);
  for (int i = 0; i < n - 1; i++) {
    if (p[i].second > p[i + 1].second) {
      p[i + 1].second = p[i + 1].first;
    }
  }
  cout << p[n - 1].second << '\n';
  return 0;
}
