#include<iostream>
#include<map>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
long long N;
while (cin>>N)
{
//cin >> N;
map<long long, long long> X;
for (size_t i = 0; i < N; i++)
{
long long x, y;
cin >> x >> y;
X.insert(make_pair(x, y));
}
long long max_x = 0;
long long max_y = 0;
map<long long, long long> maptest;
map<long long, long long>::iterator ittest;
map<long long, long long>::iterator it;
for (it = X.begin(), ittest = X.begin();it != X.end();++it)
{
maptest.insert(make_pair(it->first, it->second));
if (maptest.size() > 1)
{
if ((it->first > max_x) && (it->second > max_y))
{
maptest.erase(max_x);
//it++;
}
}
max_x = it->first;
max_y = it->second;
}
for (it = maptest.begin();it != maptest.end();++it)
{
cout << it->first << " " << it->second << endl;
}
}
return 0;
}