#include <bits/stdc++.h>
using namespace std;
vector <pair <pair <int, int>, int> > el;
vector <pair <int, int> > newel;
int memo[5000];
int main(){
int sz;
int iq;
int cont = 0;
while(cin >> sz >> iq){
el.push_back(make_pair(make_pair(sz,iq),cont));
cont++;
}
sort(el.begin(), el.end());
int aux = el[0].first.second;
int auxp = el[0].second;
for(int i=1; i<el.size(); i++){
if(el[i].first.first == el[i-1].first.first){
if(el[i].first.second > aux){
aux = el[i].first.second;
auxp = el[i].second;
}
}
else{
newel.push_back(make_pair(aux, auxp));
aux = el[i].first.second;
auxp = el[i].second;
}
}
for(int i=0; i<newel.size(); i++){
cout << newel[i].first << " " << newel[i].second << endl;
}
//vector < vector <int> > ans(newel.size());
//ans[0].push_back(newel[0].second);
/*for(int i=1; i<newel.size(); i++){
for(int j=0; j<i; j++){
if((newel[i].first < newel[j].first) && (ans[i].size() < ans[j].size()+1)) ans[i] = ans[j];
}
ans[i].push_back(newel[i].second);
}*/
/*int maxi = ans[0].size();
int auxp2 = 0;
for(int i=0; i<ans.size(); i++){
if(maxi < ans[i].size()){
maxi = ans[i].size();
auxp2 = i;
}
cout << ans[i].size() << endl;
}*/
//cout << maxi << '\n';
/*for(int i=0; i<ans[auxp2].size(); i++){
cout << ans[auxp2][i] << '\n';
}*/
return 0;
}