#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct cmp
{
bool operator ()(pair<int,int>a,pair<int,int>b)
{
if (a.first!=b.first)
return a.first>b.first;
return a.second>b.second;
}
};
int main()
{
priority_queue< pair<int, int> ,vector<pair<int,int>>,cmp > a;
pair<int, int> b(1, 2);
pair<int, int> c(1, 3);
pair<int, int> d(2, 5);
a.push(d);
a.push(c);
a.push(b);
pair<int,int> x(1,2);
x.first=9;
a.push(x);
while (!a.empty())
{
cout << a.top().first << ' ' << a.top().second << '\n';
a.pop();
}
}