fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. int n;
  10. cin >> n;
  11. vector<pair<int,int>> a(n);
  12. for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second;
  13. sort(a.begin(),a.end());
  14. for(int i=0;i<n;i++) cout << a[i].first << " " << a[i].second << " ";
  15. cout << '\n';
  16. }
  17.  
  18. int main(){
  19. ios::sync_with_stdio(false);
  20. cin.tie(nullptr);
  21.  
  22. int t;
  23. cin >> t;
  24. while (t--) solve();
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5304KB
stdin
4
2
1 4
2 3
3
3 2
4 3
2 1
5
5 10
2 3
9 6
4 1
8 7
1
10 20
stdout
1 4 2 3 
2 1 3 2 4 3 
2 3 4 1 5 10 8 7 9 6 
10 20