#include <bits/stdc++.h>

using namespace std;

void solve(){
    int n;
    cin >> n;
    int mx = 0;
    int mn = 0;
    for(int i = 0; i < n; ++i){
        int w, h;
        cin >> w >> h;
        mx = max(mx, min(h, w));
        mn = max(mn, max(h, w));
    }
    cout << mn << ' ' << mx << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    solve();
    // TIP See CLion help at <a href="https://www.jetbrains.com/help/clion/">jetbrains.com/help/clion/</a>. Also, you can try interactive lessons for CLion by selecting 'Help | Learn IDE Features' from the main menu.
}