#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    int a[n], b[n];
    int arr = 2100000000;
    bool t = false;

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (a[i] <= b[i]) {
            arr = min(arr, b[i]);
            t = true;
        }
    }

    if (!t){
        cout << -1;
        return 0;
    }
    cout << arr;

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: