stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

    int n,m;

    cin>>n>>m;

    int p[100000],y[100000];

    vector<int> v[100001];

    for(int i=0;i<m;i++){

        cin>>p[i]>>y[i];

        v[p[i]].push_back(y[i]);

    }

    for(int i=1;i<=n;i++){

        sort(v[i].begin(),v[i].end());

    }

    for(int i=0;i<m;i++){

        cout<<setfill('0')<<setw(6)<<p[i];

        cout<<setfill('0')<<setw(6);

        cout<<lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin()+1<<endl;

    }

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MOD=1e9+7;

const int INF=1e9;



int main(){

    int n,m;

    cin>>n>>m;

    vector<int> v[n];

    int p[m],y[m];

    for(int i=0;i<m;i++){

        cin>>p[i]>>y[i];

        v[--p[i]].push_back(y[i]);

    }

    for(int i=0;i<n;i++){

        sort(v[i].begin(),v[i].end());

        //v[i].erase(unique(v[i].begin(),v[i].end()),v[i].end());

    }

    for(int i=0;i<m;i++){

        int t=lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin();

        printf("%06d%06d\n",p[i]+1,t+1);

    }

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(n);i++)

#define ALL(v) (v).begin(),(v).end()

#define int long long

using namespace std;

typedef vector<int>   vint;

typedef pair<int,int> pint;



const int SZ=100005;

set<int> st[SZ];

pint id[SZ];

map<int,int> year_to_idx;



signed main()

{

    int N,M;

    cin>>N>>M;

    REP(i,M){

        int p,y; cin>>p>>y;

        year_to_idx[y]=i;

        st[p-1].insert(y);

    }



    REP(p,N){

        if(st[p].size()==0) continue;

        int cnt=1;

        for(auto y:st[p]){

            int idx=year_to_idx[y];

            id[idx].first=p+1;

            id[idx].second=cnt;

            cnt++;

        }

    }



    REP(i,M){

        printf("%06lld%06lld\n",id[i].first,id[i].second);

    }



}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(n);i++)

#define ALL(v) (v).begin(),(v).end()

#define int long long

using namespace std;

typedef vector<int>   vint;

typedef pair<int,int> pint;



const int SZ=100005;



vector<pint> v[SZ];

pint id[SZ];



signed main()

{

    int N,M;

    cin>>N>>M;



    REP(i,M){

        int p,y; cin>>p>>y;

        v[p-1].push_back(pint(y,i));

    }

    

    REP(i,N){

        if(v[i].empty()) continue;

        sort(ALL(v[i]));

        REP(j,v[i].size()){

            int idx=v[i][j].second;

            id[idx]=pint(i+1,j+1);

        }

    }

    

    REP(i,M){

        printf("%06lld%06lld\n",id[i].first,id[i].second);

    }



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int N, M;

int P[100005], Y[100005];

vector<int> yd[100005];

int main()

{

  cin >> N >> M;

  for (int i = 0; i < M; i++)

  {

    cin >> P[i] >> Y[i];

    yd[P[i]].push_back(Y[i]);

  }

  for (int i = 0; i < N; i++)

    sort(yd[i + 1].begin(), yd[i + 1].end());

  for (int i = 0; i < M; i++)

  {

    printf("%06d", P[i]);

    printf("%06d\n", lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1);

  }



  return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define rep(i, m, n) for (int i = m; i < n; ++i)



int main() {

  int N, M;

  cin >> N >> M;

  vector<int> P(M), Y(M);

  vector<vector<int>> A(N + 1,vector<int>());

  rep(i, 0, M) {

    cin >> P[i] >> Y[i];

    A[P[i]].push_back(Y[i]);

  }

  rep(i, 1, N + 1) sort(A[i].begin(), A[i].end());

  rep(i, 0, M) {

    int n = lower_bound(A[P[i]].begin(), A[P[i]].end(), Y[i]) - A[P[i]].begin();

    printf("%06d%06d\n", P[i], n + 1);

  }

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <vector>

#include <algorithm>

using namespace std;

typedef long long ll;

#define rep(i,n) for (int i=0; i<n; i++)

int N , M;

int P [100000] , Y [100000];

vector < int > yd [100001];





int main ()

{

scanf("%d%d", &N, &M);

rep(i, M) scanf("%d%d", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);

rep(i, N) sort(yd[i+1].begin(), yd[i+1].end());

rep(i, M) printf("%012lld\n" , ll(P[i])*1000000+ int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin())+1);

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include<sstream>

#include<string>

#include<vector>

#include <cmath>

#include <limits>

#include <queue>

#include<algorithm>

#include <map>

#include <stack>

#include <iomanip>

#include <cstdio>





using namespace std;

 

#define rep(i,n) for (int (i)=0;(i)<(n);i++)





/*int binarySearch(vector<int > v, int target){

  int l = 0, r = v.size();

  int mid;

  while (l+1<r){

    mid = (r+l)/2;

    if (v[mid] <= target){

      l = mid;

    }

    else r = mid;

  }

  return l;

}*/





int main(){

  int n, m;

  cin >> n >> m;

  int p[m];

  int y[m];

  vector<int> id[n];

  rep(i,m){

    scanf("%d%d", &p[i], &y[i]), id[p[i]-1].push_back(y[i]);

  }

  rep(i,n){

    sort(id[i].begin(),id[i].end());

  }



  int res;

  rep(i,m){

    res = lower_bound(id[p[i]-1].begin(), id[p[i]-1].end(), y[i])-id[p[i]-1].begin();

    cout<< setfill('0') << setw(6)  << p[i];

    cout << setfill('0') << setw(6)  << res+1 << endl;

  }  

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <iomanip>

#include <ios>

#include <iostream>

using namespace std;

const int MAX = 100000;



int main() {

  int N, M, P, Y;

  cin >> N >> M;

  pair<pair<int, int>, int> city[MAX];

  pair<int, int> ans[MAX];

  for (int i = 0; i < M; i++) {

    cin >> P >> Y;

    city[i] = make_pair(make_pair(P, Y), i);

  }

  sort(city, city + M);

  for (int i = 0, c = 1; i < M;

       i++, c = i < M && city[i - 1].first.first == city[i].first.first ? c + 1

                                                                        : 1)

    ans[city[i].second] = make_pair(city[i].first.first, c);



  for (int i = 0; i < M; i++) {

    cout << setfill('0') << right << setw(6) << ans[i].first;

    cout << setfill('0') << right << setw(6) << ans[i].second;

    cout << endl;

  }

  return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int N, M;

  cin >> N >> M;

  vector<int> P(M), Y(M);

  for (int i = 0; i < M; i++) {

    cin >> P[i] >> Y[i];

  }

  vector<int> idx(M);

  iota(idx.begin(), idx.end(), 0);

  sort(idx.begin(), idx.end(), [&](int a, int b) { return Y[a] < Y[b]; });

  vector<int> cnts(N + 1, 0);



  vector<pair<int, int>> res(M);



  for (auto i : idx) {

    res[i] = make_pair(P[i], cnts[P[i]]++);

  }



  for (int i = 0; i < M; i++) {

    cout << setfill('0') << right << setw(6) << res[i].first;

    cout << setfill('0') << right << setw(6) << res[i].second + 1;

    cout << '\n';

  }

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <vector>

#include <set>

#include <iomanip>

using namespace std;



inline int POS(int k,int value);



const int MAXN = 2e5+10;



struct P {

    int x,y;

} H[MAXN];



vector<int> G[MAXN];



set<int> s;

set<int>::iterator it;



int main()

{

    int N,M;

	cin>>N>>M;

	

    for(int i=1; i<=M; i++) {

        int x,y;

		cin>>x>>y;

		

        H[i].x = x;

		H[i].y = y;

		

        s.insert(x);

		G[x].push_back(y);

    }

    

    for(int i=1; i<=N; i++) {

        sort(G[i].begin(), G[i].end());

    }

    

    for(int i=1; i<=M; i++) {

        cout<<setw(6)<<setfill('0')<<H[i].x

			<<setw(6)<<setfill('0')<<POS(H[i].x, H[i].y)+1<<endl;

    }

    

    return 0;

}



inline int POS(int k,int value) {

    for(int left = 0, len = G[k].size(), right = len - 1; left <= right ;) {

        int mid = left + (right - left) / 2;

        if(G[k][mid] == value) {

        	return mid;

		} else if(G[k][mid] > value) {

        	right = mid;

		} else {

        	left = mid + 1;

		}

    }

    return -1;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



struct data2

{

	int p, y, nn, num;

}c[100010];



bool cmp(data2 u, data2 v)

{

	if (u.p == v.p) return u.y<v.y;

	return u.p < v.p; 

}

bool cmp2(data2 u, data2 v)

{

	return u.nn < v.nn; 

}



int ans[100010];



int main()

{

	int n, m;

	scanf("%d%d", &n, &m);

	for (int i = 1; i <= m; ++i)

		scanf("%d%d", &c[i].p, &c[i].y), c[i].nn = i;

	sort(c+1, c+m+1, cmp);

	for (int i=1, j=1; i <= m; i=j)

	{

		int k = 0;

		while (j <= m && c[j].p == c[i].p) 

		{

			++k;

			c[j].num = k;

			++j; 

		}

	}

	sort(c+1, c+m+1, cmp2);

	for (int i = 1; i <= m; ++i)

		printf("%06d%06d\n", c[i].p, c[i].num);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define  ll  long long

#define  pi  pair<int,int>

#define  pb  push_back

#define  F   first

#define  S   second

const int N=1e5+3;

vector<int>v[N];

string s,p,t,ans[N];

map<pi,int>mp;

int main()

{

    ft

    int i,j,n,k,m,l,r;

    cin>>n>>m;

    for(i=0; i<m; i++)

    {

        cin>>l>>r;

        v[l].pb(r);

        mp[{l,r}]=i+1;

    }

    for(i=1; i<=n; i++)

    {

        sort(v[i].begin(),v[i].end());

        int sz=v[i].size();

        if(sz>0)

        {

            for(int z=0; z<sz; z++)

            {

                s.clear();

                p.clear();

                l=0;

                r=i;

                while(r!=0)

                {

                    s+=((r%10)+48);

                    r/=10;

                    l++;

                }

                for(k=0; k<(6-l); k++)

                {

                    p+='0';

                }

                reverse(s.begin(),s.end());

                t=p+s;

                l=0;

                r=z+1;

                s.clear();

                p.clear();

                while(r!=0)

                {

                    s+=((r%10)+48);

                    r/=10;

                    l++;

                }

                for(k=0; k<(6-l); k++)

                {

                    p+='0';

                }

                reverse(s.begin(),s.end());

                int cc=mp[{i,v[i][z]}];

                ans[cc]=t+p+s;

            }

        }

    }

    for(i=1;i<=m;i++)

    {

        cout<<ans[i]<<"\n";

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



struct data2

{

	int p, y, nn, num;

}c[100010];



bool cmp(data2 u, data2 v)

{

	if (u.p == v.p) return u.y<v.y;

	return u.p < v.p; 

}

bool cmp2(data2 u, data2 v)

{

	return u.nn < v.nn; 

}



int ans[100010];



int main()

{

	int n, m;

	scanf("%d%d", &n, &m);

	for (int i = 1; i <= m; ++i)

		scanf("%d%d", &c[i].p, &c[i].y), c[i].nn = i;

	sort(c+1, c+m+1, cmp);

	for (int i=1, j=1; i <= m; i=j)

	{

		int k = 0;

		while (j <= m && c[j].p == c[i].p) 

		{

			++k;

			c[j].num = k;

			++j; 

		}

	}

	sort(c+1, c+m+1, cmp2);

	for (int i = 1; i <= m; ++i)

		printf("%06d%06d\n", c[i].p, c[i].num);

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
// https://atcoder.jp/contests/abc113/tasks/abc113_c

#include <algorithm>

#include <climits>

#include <iomanip>

#include <iostream>

#include <string>

#include <tuple>

#include <vector>

using namespace std;



typedef long long ll;

const int INF = 1e9;

const int MOD = 1e9 + 7;

const ll LINF = 1e18;



#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

#define REP(i, n) for (int i = 0; i < (n); ++i)

#define REPR(i, n) for (int i = n; i >= 0; i--)

#define FOREACH(x, a) for (auto &(x) : (a))



// No、市、年、順位

typedef tuple<int, int, int, int> mytuple;



// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



// 年でソート（0番目から数えて2番目）

bool mycompare(const mytuple &lhs, const mytuple &rhs) {

    return get<2>(lhs) < get<2>(rhs);

}



int main() {

    int n, m, t1, t2;

    ios::sync_with_stdio(false);

    cin.tie(0);

    cin >> n >> m;

    mytuple tu[m];



    REP(i, m) {

        cin >> t1 >> t2;

        tu[i] = make_tuple(i, t1, t2, 0);

    }

    //年でソート

    sort(tu, tu + m, mycompare);



    // 市の出現回数をメモ

    int cnt[n + 1];

    REP(i, n + 1) cnt[i] = 0;

    REP(i, m) {

        int ct = get<1>(tu[i]);

        cnt[ct]++;

        tu[i] = make_tuple(get<0>(tu[i]), get<1>(tu[i]), get<2>(tu[i]), cnt[ct]);

    }

    // 入力順でソート

    sort(tu, tu + m);

    REP(i, m) {

        cout << setw(6) << std::setfill('0') << (get<1>(tu[i]));

        cout << setw(6) << std::setfill('0') << (get<3>(tu[i])) << endl;

    }



    return 0;

}


// Optimized solution to the same problem (faster):
// https://atcoder.jp/contests/abc113/tasks/abc113_c

#include <algorithm>

#include <cstdio>

#include <tuple>

using namespace std;



typedef long long ll;

const int INF = 1e9;

const int MOD = 1e9 + 7;

const ll LINF = 1e18;



#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

#define REP(i, n) for (int i = 0; i < (n); ++i)

#define REPR(i, n) for (int i = n; i >= 0; i--)

#define FOREACH(x, a) for (auto &(x) : (a))



// No、市、年、順位

typedef tuple<int, int, int, int> mytuple;



// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



// 年でソート（0番目から数えて2番目）

bool mycompare(const mytuple &lhs, const mytuple &rhs) {

    return get<2>(lhs) < get<2>(rhs);

}



int main() {

    int n, m, t1, t2;

    scanf("%d%d", &n, &m);

    mytuple tu[m];



    REP(i, m) {

        scanf("%d%d", &t1, &t2);

        tu[i] = make_tuple(i, t1, t2, 0);

    }

    // 年でソート

    sort(tu, tu + m, mycompare);



    // 市の出現回数をメモ

    int cnt[n + 1];

    REP(i, n + 1) cnt[i] = 0;

    REP(i, m) {

        int city = get<1>(tu[i]);

        cnt[city]++;

        tu[i] =

            make_tuple(get<0>(tu[i]), get<1>(tu[i]), get<2>(tu[i]), cnt[city]);

    }

    // 入力順でソート

    sort(tu, tu + m);

    REP(i, m) { printf("%06d%06d\n", get<1>(tu[i]), get<3>(tu[i])); }



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<vector>

#include<map>

using namespace std;

const int maxn = 1e5 + 1;

struct node{

	int p,y;

	int num;

	int sub;

}no;

vector<node> v[maxn];

bool cmp(node a,node b){

	return a.y<b.y;

}

int main(){

	int n,m,p,y;

	cin>>n>>m;

	map<int,node> Map;

	for(int i=1;i<=m;i++){

		cin>>p>>y;

		no.p=p;no.y=y;

		no.sub=i;

		Map[i]=no;

		v[p].push_back(no);

	}

	for(int i=1;i<=n;i++){

		sort(v[i].begin(),v[i].end(),cmp);

		for (int j=0;j<v[i].size();j++){

        	Map[v[i][j].sub].num=j+1;

    	}

	}

	for(int i=1;i<=m;i++){

		printf("%06d%06d\n",Map[i].p,Map[i].num);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

    scanf("%d%d", &m, &n);

    for (int i = 1; i <= n; i++) {

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

    sort(node + 1, node + n + 1, cmp);

    int cnt = 1;

    for (int i = 1; i <= n; i++)

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

    for (int i = 1; i <= n; i++)

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

#include <algorithm>

#include <cstdio>

using namespace std;

struct node

{

	int num;

	int xian;

	int shi;

	int time;

}d[100005];

bool cmp1(node a,node b)

{

	if(a.xian<b.xian)return true;

	else if(a.xian==b.xian)

	{

		if(a.time<b.time)return true;

		else return false;

	}

	return false;

	

}

bool cmp2(node a,node b)

{

	return a.num<b.num;

}

int main()

{

	int n,m;

	cin>>n>>m;

	for(int i=1;i<=m;i++)

	{

		cin>>d[i].xian>>d[i].time;

		d[i].num=i;

	}

	sort(d+1,d+m+1,cmp1);

	int cnt=1;

	for(int i=1;i<=m;i++)

	{

		if(i!=1&&d[i].xian!=d[i-1].xian)cnt=1;

		d[i].shi=cnt;

		cnt++;

	}

	sort(d+1,d+m+1,cmp2);

	for(int i=1;i<=m;i++)

	{

		printf("%06d%06d\n",d[i].xian,d[i].shi);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

    scanf("%d%d", &m, &n);

    for (int i = 1; i <= n; i++) {

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

    sort(node + 1, node + n + 1, cmp);

    int cnt = 1;

    for (int i = 1; i <= n; i++)

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

    for (int i = 1; i <= n; i++)

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

 

struct node{

	int p,y;

}x[100005];

 

bool cmp(node a,node b)

{

	if(a.p==b.p) return a.y<b.y;

	return a.p<b.p;

}

 

int a[100005],b[100005];

 

map<pair<int , int >,int >m1;

 

int main()

{

	int n,m;

	scanf("%d%d",&n,&m);

	for(int i=1;i<=m;i++)

	{

		scanf("%d%d",&a[i],&b[i]);

		x[i].p=a[i];

		x[i].y=b[i];	

	}

	sort(x+1,x+m+1,cmp);

	int t=0,tt=1;

	for(int i=1;i<=m;i++)

	{

		if(x[i].p==t){

			m1[make_pair(x[i].p,x[i].y)]=tt;

			tt++;

		}

		else{

			m1[make_pair(x[i].p,x[i].y)]=1;

			tt=2;

			t=x[i].p;

		}

	}

	for(int i=1;i<=m;i++)

	{		

		printf("%06d%06d\n",a[i],m1[make_pair(a[i],b[i])]);

	}

	return 0;

} 

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

    scanf("%d%d", &m, &n);

    for (int i = 1; i <= n; i++) {

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

    sort(node + 1, node + n + 1, cmp);

    int cnt = 1;

    for (int i = 1; i <= n; i++)

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

    for (int i = 1; i <= n; i++)

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <string>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

const int MAX=1e5+5;

struct city

{

	int P;

	int Y;

	int num;

	int x;

}c[MAX];

bool cmp1(city a,city b)

{

	if(a.P==b.P)

		return a.Y<b.Y;

	else

		return a.P<b.P;

}

bool cmp2(city a,city b)

{

	return a.num<b.num;

}

int main(int argc, char *argv[])

{

	int n,m;

	cin>>n>>m;

	for(int i=0;i<m;i++)

		{cin>>c[i].P>>c[i].Y;c[i].num=i+1;}

	sort(c,c+m,cmp1);

	int x=c[1].P;

	int y=1;

	for(int i=0;i<m;i++)

	{

		if(x!=c[i].P)

		{

			x=c[i].P;

			y=1;

		}

		c[i].x=y;

		y++;

	}

	sort(c,c+m,cmp2);

	for(int i=0;i<m;i++)

		printf("%06d%06d\n",c[i].P,c[i].x);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

    scanf("%d%d", &m, &n);

    for (int i = 1; i <= n; i++) {

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

    sort(node + 1, node + n + 1, cmp);

    int cnt = 1;

    for (int i = 1; i <= n; i++)

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

    for (int i = 1; i <= n; i++)

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<vector> 

#include<map>

using namespace std;

const int M=1e5+5;

struct node{

	int p,y;

	int k,num;

}q;

bool comp(node a,node b){

	return a.y<b.y;

}

vector<node> a[M];

map<int,node> Map;

int main(){

    int n,m;

    cin>>n>>m;

    for(int i=1;i<=m;i++){

    	int p,y;

    	cin>>p>>y;

    	q.p=p; q.y=y;

    	q.k=i;

    	Map[i]=q;

    	a[p].push_back(q);

	}

	for(int i=1;i<=n;i++){

		sort(a[i].begin(),a[i].end(),comp);

		for(int j=0;j<a[i].size();j++)

			Map[a[i][j].k].num=j+1;	

	}

	for(int i=1;i<=m;i++)

		printf("%06d%06d\n",Map[i].p,Map[i].num);

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxn = 1e5 + 5;

typedef struct Node {

    int id, p, y, s;

} Node;

Node node[maxn] = { 0 };

bool cmp(Node &a, Node &b) {

    if (a.p == b.p) return a.y < b.y;

    return a.p < b.p;

}

bool cov(Node &a, Node &b) {

    return a.id < b.id;

}



int main() {

    int n, m;

    scanf("%d%d", &m, &n);

    for (int i = 1; i <= n; i++) {

        scanf("%d%d", &node[i].p, &node[i].y);

        node[i].id = i;

    }

    sort(node + 1, node + n + 1, cmp);

    int cnt = 1;

    for (int i = 1; i <= n; i++)

        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;

        else node[i].s = cnt = 1;

    sort(node + 1, node + n + 1, cov);

    for (int i = 1; i <= n; i++)

        printf("%06d%06d\n", node[i].p, node[i].s);

    return 0;

}


// Fastest known solution for this problem: