#include <bits/stdc++.h>
int ch[10000] = {0};
void checker(int a, int b) {
  int i;
  for (i = 0; i < 10000; i++) {
    if (i < a - 2 || b - 2 < i) {
      ch[i] = 1;
    }
  }
}
int main(void) {
  int a, b, n, i, result;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    checker(a, b);
  }
  i = 9999;
  while (ch[i] == 1) i--;
  printf("%d\n", i + 1);
  return 0;
}
