#include <bits/stdc++.h>   using namespace std;   void solve() {     pair<int, int> A[50007];     int n;     cin >> n;     for (int i = 0; i < (n); i++) cin >> A[i].first >> A[i].second;     sort(A, A + n);     int r1 = A[0].first, r2 = A[0].second;     int r3, r4;     for (int i = 1; i < n; i++) {       if (A[i].first >= r1 || A[i].first >= r2) {         r3 = A[i].first;       } else         r3 = 1000000009;       if (A[i].second >= r1 || A[i].second >= r2) {         r4 = A[i].second;       } else         r4 = 1000000009;       r1 = r3, r2 = r4;     }     printf( %d n , min(r1, r2));   }   int main() {     int T = 1;     for (int i = 1; i <= T; i++) {       solve();     }     return 0;   }   