#include<queue>
#include<iostream>
using namespace std;

struct node1
{
	bool operator () (int &a,int &b)  //或者(int a,int b)
	{
		return a>b;
	}
};  //优先级为小的  可以用less<int>替换

struct node2
{
	bool operator () (int a,int b)
	{
		return a<b;
	}
};  //优先级为大的  可以用greater<int>替换

struct node3
{
	int x,y;
	friend bool operator < (node3 a,node3 b)
	{
		return a.x>b.x;
	}
}k;  //结构体优先队列

int main()
{
	freopen("e:\\input.txt","r",stdin);
	freopen("e:\\output.txt","w",stdout);
	int i;
//	priority_queue<int,vector<int>,node1> q;
//	priority_queue<int,vector<int>,node2> q;
//	priority_queue<node3> q;
	while(cin>>k.x>>k.y)
		q.push(k);
	while(!q.empty())
	{
		node3 s=q.top();
		cout<<s.x<<" "<<s.y<<endl;
		q.pop();
	}
	return 0;
}


/*简便用法*/
小的先出:
priority_queue<int,vector<int>,greater<int> >
大的先出:
priority_queue<int,vector<int>,less<int> >
优先队列默认大的先出