文件目录

#include <bits/stdc++.h>
using namespace std;
map<int, int> qj;
int n, u, v;
int main()
{
    cin >> n;
    while (n--)
    {
        cin >> u >> v;
        if (!qj[u] || qj[u] < v)
            qj[u] = v;
    }
    auto i = qj.begin();
    int l = i->first;
    int r = i->second;
    for (i++; i != qj.end(); i++)
    {
        if (i->first > r)
        {
            cout << "no";
            return 0;
        }
        else
        {
            l = min(l, i->first);
            r = max(r, i->second);
        }
    }
    cout << l << " " << r;
    return 0;
}