#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

bool compare(const pair<int, int> &a, const pair<int, int> &b)
{
    if(a.first == b.first)
    {
        return a.second < b.second;
    }
    else {
        return a.first < b.first;
    }
}
int main() {
    int n;
    cin >> n;
    
    int arr[n];
    int narr[n];
    
    vector<pair<int,int>> tnjj;
    
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
        cin >> narr[i];
        tnjj.push_back(pair(arr[i],narr[i]));
    }
    sort(tnjj.begin(),tnjj.end(),compare);
    for(int i = 0;i < n;i++)
    {
        cout << tnjj[i].first << " ";
        cout << tnjj[i].second << endl;

    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: