#include <bits/stdc++.h>
using namespace std;
bool compare(pair<int, int> a, pair<int, int> b){
return (a.first > b.first) || (a.first == b.first && a.second < b.second);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--){
int n;
cin >> n;
vector<pair<int, int>> coordinates(n);
for(int i=0; i<n; i++){
cin >> coordinates[i].first >> coordinates[i].second;
}
sort(coordinates.begin(), coordinates.end(), compare);
reverse(coordinates.begin(), coordinates.end());
for(int i=0; i<n; i++){
cout << coordinates[i].first << " " << coordinates[i].second << endl;
}
}
return 0;
}
created
last reply
- 1
reply
- 440
views
- 2
users
- 1
like