stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <string>

using namespace std;



struct CITY{

    //int id;

    int p;

    int year;

    int no;

};

CITY citys[100000];

string ids[100000];



int cmp(CITY a, CITY b)

{

    if(a.p!=b.p)

    {

        return a.p<b.p;

    }

    else

    {

        return a.year<b.year;

    }

}



string id2String(int data)

{

    string s="";

    int i,d;

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

    {

        d = data%10;

        data = data/10;

        s = to_string(d)+s;

    }

    return s;

}





int main()

{

 int N,M;

 int i,j,number=1,p_pre=0,data2;

 char s[6],d[6],id[12];



 cin>>N>>M;

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

 {

     citys[i].no = i;

     cin>>citys[i].p>>citys[i].year;

 }

 sort(citys, citys+M,cmp);



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

 {

     if(p_pre == citys[i].p)

     {

        number++;

     }

     else

     {

         number=1;

         p_pre = citys[i].p;

     }

     ids[citys[i].no] = id2String(citys[i].p)+id2String(number);

 }



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

 {

    cout<<ids[i]<<endl;

 }

 return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.3705936372331955x):
#include <bits/stdc++.h>

using namespace std;



struct T{

	int y, p, i, j;

}a[100005];



bool cmp(T a, T b){

	if(a.y == b.y)

		return a.p < b.p;

	return a.y < b.y;

}



bool cmp1(T a, T b){

	return a.i < b.i;

}



int main(){

	int n, m;

	cin >> n >> m;

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

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

		a[i].i = i;

	}

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

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

//		printf("%d %d\n",a[i].y,a[i].p);	

	int x = 1, y = 1;

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

		if(a[i].y > x){

			x = a[i].y;

			y = 1;	

		}

		a[i].j = y++;

//		printf("%06d%06d\n",x,y++);

	}

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

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

		printf("%06d%06d\n",a[i].y,a[i].j);

	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 3.3884204829827x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,d,m,f,p,y;

    string s1,s2;

    vector< pair<ll,ll> >vc;

    map<ll,ll>mp;

    map<pair<ll,ll>,ll >mp1;

    map< pair<ll,ll> ,pair<ll,ll> >mp2;

    map<pair<ll,ll>,ll >::iterator it;



    cin>>n>>m;

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

    {

        cin>>p>>y;

        vc.push_back({p,y});

        mp1[{y,p}]=1;

    }

    for(it=mp1.begin();it!=mp1.end();it++)

    {

        k=it->first.first;

        l=it->first.second;

        a=mp[l]+1;

        mp[l]++;

        mp2[{l,k}]={l,a};

    }

    for(i=0;i<vc.size();i++)

    {

        k=mp2[{vc[i].first,vc[i].second}].first;

        l=mp2[{vc[i].first,vc[i].second}].second;

        stringstream ss;

        ss<<k;

        ss>>s1;

        stringstream sf;

        sf<<l;

        sf>>s2;

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

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

        for(j=s1.size();j<6;j++){s1.push_back('0');}

        for(j=s2.size();j<6;j++){s2.push_back('0');}

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

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

        s1+=s2;

        cout<<s1<<endl;

    }

    return 0;

}
// Slower C++ solution:
#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);

}

// Faster C++ solution for the same problem (measured speedup: 3.3809390110844633x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,d,m,f,p,y;

    string s1,s2;

    vector< pair<ll,ll> >vc;

    map<ll,ll>mp;

    map<pair<ll,ll>,ll >mp1;

    map< pair<ll,ll> ,pair<ll,ll> >mp2;

    map<pair<ll,ll>,ll >::iterator it;



    cin>>n>>m;

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

    {

        cin>>p>>y;

        vc.push_back({p,y});

        mp1[{y,p}]=1;

    }

    for(it=mp1.begin();it!=mp1.end();it++)

    {

        k=it->first.first;

        l=it->first.second;

        a=mp[l]+1;

        mp[l]++;

        mp2[{l,k}]={l,a};

    }

    for(i=0;i<vc.size();i++)

    {

        k=mp2[{vc[i].first,vc[i].second}].first;

        l=mp2[{vc[i].first,vc[i].second}].second;

        stringstream ss;

        ss<<k;

        ss>>s1;

        stringstream sf;

        sf<<l;

        sf>>s2;

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

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

        for(j=s1.size();j<6;j++){s1.push_back('0');}

        for(j=s2.size();j<6;j++){s2.push_back('0');}

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

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

        s1+=s2;

        cout<<s1<<endl;

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cstring>

#include <cstdio>

#include <vector>

#include <queue>

#include <stack>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <cassert>

#include <ctime>

#include <cstdlib>

#include <map>

#include <set>

using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")

#define lowbit(x) (x&(-x))

#define max(x,y) (x>=y?x:y)

#define min(x,y) (x<=y?x:y)

//#define MAX 100000000000000000

#define MOD 1000000007

#define pi acos(-1.0)

#define ei exp(1)

#define PI 3.1415926535897932384626433832

#define ios() ios::sync_with_stdio(true)

#define INF (1<<31)-1;

#define mem(a) (memset(a,0,sizeof(a)))

struct P{

    int x,y;

}H[200000];

vector<int>G[200000];

int POS(int k,int value){

    int mid;

    int left = 0;

    int len = G[k].size();

    int right = len - 1;

    //cout<<" "<<k<<"A"<<value<<endl;

    while(left <= right){

 

        // 确保中点靠近区间的起点

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

        //cout<<mid<<endl;

        //cout<<"mid= "<<mid<<" "<<left<<" "<<right<<endl;

        // 如果找到则返回

        if(G[k][mid] == value) return mid;

        // 将中点赋给终点

        else if(G[k][mid] > value) right = mid;

        // 将中点加一赋给起点

        else left = mid + 1;

    }

    return -1;

}

set<int>::iterator it;

int main()

{

    set<int>s;

    int N,M;

    int x,y;

    cin>>N>>M;

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

        cin>>x>>y;

        H[i].x = x;

        H[i].y = y;

        G[x].push_back(y);

        s.insert(x);

    }

    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;

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

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.216545937608364x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,d,m,f,p,y;

    string s1,s2;

    vector< pair<ll,ll> >vc;

    map<ll,ll>mp;

    map<pair<ll,ll>,ll >mp1;

    map< pair<ll,ll> ,pair<ll,ll> >mp2;

    map<pair<ll,ll>,ll >::iterator it;



    cin>>n>>m;

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

    {

        cin>>p>>y;

        vc.push_back({p,y});

        mp1[{y,p}]=1;

    }

    for(it=mp1.begin();it!=mp1.end();it++)

    {

        k=it->first.first;

        l=it->first.second;

        a=mp[l]+1;

        mp[l]++;

        mp2[{l,k}]={l,a};

    }

    for(i=0;i<vc.size();i++)

    {

        k=mp2[{vc[i].first,vc[i].second}].first;

        l=mp2[{vc[i].first,vc[i].second}].second;

        stringstream ss;

        ss<<k;

        ss>>s1;

        stringstream sf;

        sf<<l;

        sf>>s2;

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

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

        for(j=s1.size();j<6;j++){s1.push_back('0');}

        for(j=s2.size();j<6;j++){s2.push_back('0');}

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

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

        s1+=s2;

        cout<<s1<<endl;

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<stdio.h>

#include<string.h>

#include<vector>

using namespace std;

typedef  long long ll;

int N,M,P,Y;

const int maxm=(int)1e5+5;

struct city{

int p;

int y;

int i;

int flag;

city(){

    flag = 0;

}

};

city C[maxm];

int tot;

bool cmp1(city city1,city city2){

    return city1.p<city2.p ||(city1.p==city2.p&&city1.y<city2.y);

}

bool cmp2(city city1,city city2){

    return city1.i<city2.i;

}

int main(){

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

    tot=0;

    memset(C,0,sizeof(C));

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

        struct city tmp;

        scanf("%d%d",&P,&Y);

        tmp.p=P;tmp.y=Y;tmp.i=i;

        C[tot]=tmp;

        tot++;

    }

    sort(C,C + M,cmp1);

    C[0].flag=1;

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

        if(C[i].p==C[i-1].p)C[i].flag=C[i-1].flag+1;

        else C[i].flag=1;

    }

     sort(C,C + M,cmp2);

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

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

     }

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

      //  cout<<"p:"<<C[i].p<<"y:"<<C[i].y<<"flag:"<<C[i].flag<<"i:"<<C[i].i<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.9528423731204914x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,d,m,f,p,y;

    string s1,s2;

    vector< pair<ll,ll> >vc;

    map<ll,ll>mp;

    map<pair<ll,ll>,ll >mp1;

    map< pair<ll,ll> ,pair<ll,ll> >mp2;

    map<pair<ll,ll>,ll >::iterator it;



    cin>>n>>m;

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

    {

        cin>>p>>y;

        vc.push_back({p,y});

        mp1[{y,p}]=1;

    }

    for(it=mp1.begin();it!=mp1.end();it++)

    {

        k=it->first.first;

        l=it->first.second;

        a=mp[l]+1;

        mp[l]++;

        mp2[{l,k}]={l,a};

    }

    for(i=0;i<vc.size();i++)

    {

        k=mp2[{vc[i].first,vc[i].second}].first;

        l=mp2[{vc[i].first,vc[i].second}].second;

        stringstream ss;

        ss<<k;

        ss>>s1;

        stringstream sf;

        sf<<l;

        sf>>s2;

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

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

        for(j=s1.size();j<6;j++){s1.push_back('0');}

        for(j=s2.size();j<6;j++){s2.push_back('0');}

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

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

        s1+=s2;

        cout<<s1<<endl;

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <string>

using namespace std;



struct CITY{

    //int id;

    int p;

    int year;

    int no;

};

CITY citys[100000];

string ids[100000];



int cmp(CITY a, CITY b)

{

    if(a.p!=b.p)

    {

        return a.p<b.p;

    }

    else

    {

        return a.year<b.year;

    }

}



string id2String(int data)

{

    string s="";

    int i,d;

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

    {

        d = data%10;

        data = data/10;

        s = to_string(d)+s;

    }

    return s;

}





int main()

{

 int N,M;

 int i,j,number=1,p_pre=0,data2;

 char s[6],d[6],id[12];



 cin>>N>>M;

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

 {

     citys[i].no = i;

     cin>>citys[i].p>>citys[i].year;

 }

 sort(citys, citys+M,cmp);



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

 {

     if(p_pre == citys[i].p)

     {

        number++;

     }

     else

     {

         number=1;

         p_pre = citys[i].p;

     }

     ids[citys[i].no] = id2String(citys[i].p)+id2String(number);

 }



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

 {

    cout<<ids[i]<<endl;

 }

 return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.198530311917584x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main()

{

    ll n,i,j,k,l,a,b,c,d,m,f,p,y;

    string s1,s2;

    vector< pair<ll,ll> >vc;

    map<ll,ll>mp;

    map<pair<ll,ll>,ll >mp1;

    map< pair<ll,ll> ,pair<ll,ll> >mp2;

    map<pair<ll,ll>,ll >::iterator it;



    cin>>n>>m;

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

    {

        cin>>p>>y;

        vc.push_back({p,y});

        mp1[{y,p}]=1;

    }

    for(it=mp1.begin();it!=mp1.end();it++)

    {

        k=it->first.first;

        l=it->first.second;

        a=mp[l]+1;

        mp[l]++;

        mp2[{l,k}]={l,a};

    }

    for(i=0;i<vc.size();i++)

    {

        k=mp2[{vc[i].first,vc[i].second}].first;

        l=mp2[{vc[i].first,vc[i].second}].second;

        stringstream ss;

        ss<<k;

        ss>>s1;

        stringstream sf;

        sf<<l;

        sf>>s2;

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

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

        for(j=s1.size();j<6;j++){s1.push_back('0');}

        for(j=s2.size();j<6;j++){s2.push_back('0');}

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

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

        s1+=s2;

        cout<<s1<<endl;

    }

    return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 3.525759474300202x):
#include<bits/stdc++.h>

using namespace std;



int n,m;



struct az

{

	int p;

	int y;

	int cnt;

}q[100005];



struct za

{

	int p;

	int y;

    int x;

}l[100005];



bool cmp(za a, za b)

{

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

	return a.p < b.p;

}



int main()

{

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

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

	   scanf("%d%d",&q[i].p,&q[i].y),l[i].x=i,l[i].p=q[i].p,l[i].y=q[i].y;

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

	int now = 0 ;

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

	{

		if(l[i].p != l[i-1].p) now=0;

		q[l[i].x].cnt=++now;

	}

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

	{

		int s=q[i].p;

		int ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].p;

		s=q[i].cnt;

		ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].cnt;

		cout<<endl;

	}

	return 0;

 }
// Slower C++ solution:
#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);

}

// Faster C++ solution for the same problem (measured speedup: 3.5179747644156425x):
#include<bits/stdc++.h>

using namespace std;



int n,m;



struct az

{

	int p;

	int y;

	int cnt;

}q[100005];



struct za

{

	int p;

	int y;

    int x;

}l[100005];



bool cmp(za a, za b)

{

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

	return a.p < b.p;

}



int main()

{

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

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

	   scanf("%d%d",&q[i].p,&q[i].y),l[i].x=i,l[i].p=q[i].p,l[i].y=q[i].y;

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

	int now = 0 ;

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

	{

		if(l[i].p != l[i-1].p) now=0;

		q[l[i].x].cnt=++now;

	}

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

	{

		int s=q[i].p;

		int ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].p;

		s=q[i].cnt;

		ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].cnt;

		cout<<endl;

	}

	return 0;

 }
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cstring>

#include <cstdio>

#include <vector>

#include <queue>

#include <stack>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <cassert>

#include <ctime>

#include <cstdlib>

#include <map>

#include <set>

using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")

#define lowbit(x) (x&(-x))

#define max(x,y) (x>=y?x:y)

#define min(x,y) (x<=y?x:y)

//#define MAX 100000000000000000

#define MOD 1000000007

#define pi acos(-1.0)

#define ei exp(1)

#define PI 3.1415926535897932384626433832

#define ios() ios::sync_with_stdio(true)

#define INF (1<<31)-1;

#define mem(a) (memset(a,0,sizeof(a)))

struct P{

    int x,y;

}H[200000];

vector<int>G[200000];

int POS(int k,int value){

    int mid;

    int left = 0;

    int len = G[k].size();

    int right = len - 1;

    //cout<<" "<<k<<"A"<<value<<endl;

    while(left <= right){

 

        // 确保中点靠近区间的起点

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

        //cout<<mid<<endl;

        //cout<<"mid= "<<mid<<" "<<left<<" "<<right<<endl;

        // 如果找到则返回

        if(G[k][mid] == value) return mid;

        // 将中点赋给终点

        else if(G[k][mid] > value) right = mid;

        // 将中点加一赋给起点

        else left = mid + 1;

    }

    return -1;

}

set<int>::iterator it;

int main()

{

    set<int>s;

    int N,M;

    int x,y;

    cin>>N>>M;

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

        cin>>x>>y;

        H[i].x = x;

        H[i].y = y;

        G[x].push_back(y);

        s.insert(x);

    }

    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;

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

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.46851411949071x):
#include<bits/stdc++.h>

using namespace std;



int n,m;



struct az

{

	int p;

	int y;

	int cnt;

}q[100005];



struct za

{

	int p;

	int y;

    int x;

}l[100005];



bool cmp(za a, za b)

{

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

	return a.p < b.p;

}



int main()

{

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

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

	   scanf("%d%d",&q[i].p,&q[i].y),l[i].x=i,l[i].p=q[i].p,l[i].y=q[i].y;

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

	int now = 0 ;

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

	{

		if(l[i].p != l[i-1].p) now=0;

		q[l[i].x].cnt=++now;

	}

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

	{

		int s=q[i].p;

		int ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].p;

		s=q[i].cnt;

		ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].cnt;

		cout<<endl;

	}

	return 0;

 }
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<stdio.h>

#include<string.h>

#include<vector>

using namespace std;

typedef  long long ll;

int N,M,P,Y;

const int maxm=(int)1e5+5;

struct city{

int p;

int y;

int i;

int flag;

city(){

    flag = 0;

}

};

city C[maxm];

int tot;

bool cmp1(city city1,city city2){

    return city1.p<city2.p ||(city1.p==city2.p&&city1.y<city2.y);

}

bool cmp2(city city1,city city2){

    return city1.i<city2.i;

}

int main(){

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

    tot=0;

    memset(C,0,sizeof(C));

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

        struct city tmp;

        scanf("%d%d",&P,&Y);

        tmp.p=P;tmp.y=Y;tmp.i=i;

        C[tot]=tmp;

        tot++;

    }

    sort(C,C + M,cmp1);

    C[0].flag=1;

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

        if(C[i].p==C[i-1].p)C[i].flag=C[i-1].flag+1;

        else C[i].flag=1;

    }

     sort(C,C + M,cmp2);

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

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

     }

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

      //  cout<<"p:"<<C[i].p<<"y:"<<C[i].y<<"flag:"<<C[i].flag<<"i:"<<C[i].i<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.0725265726112716x):
#include<bits/stdc++.h>

using namespace std;



int n,m;



struct az

{

	int p;

	int y;

	int cnt;

}q[100005];



struct za

{

	int p;

	int y;

    int x;

}l[100005];



bool cmp(za a, za b)

{

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

	return a.p < b.p;

}



int main()

{

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

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

	   scanf("%d%d",&q[i].p,&q[i].y),l[i].x=i,l[i].p=q[i].p,l[i].y=q[i].y;

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

	int now = 0 ;

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

	{

		if(l[i].p != l[i-1].p) now=0;

		q[l[i].x].cnt=++now;

	}

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

	{

		int s=q[i].p;

		int ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].p;

		s=q[i].cnt;

		ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].cnt;

		cout<<endl;

	}

	return 0;

 }
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <string>

using namespace std;



struct CITY{

    //int id;

    int p;

    int year;

    int no;

};

CITY citys[100000];

string ids[100000];



int cmp(CITY a, CITY b)

{

    if(a.p!=b.p)

    {

        return a.p<b.p;

    }

    else

    {

        return a.year<b.year;

    }

}



string id2String(int data)

{

    string s="";

    int i,d;

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

    {

        d = data%10;

        data = data/10;

        s = to_string(d)+s;

    }

    return s;

}





int main()

{

 int N,M;

 int i,j,number=1,p_pre=0,data2;

 char s[6],d[6],id[12];



 cin>>N>>M;

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

 {

     citys[i].no = i;

     cin>>citys[i].p>>citys[i].year;

 }

 sort(citys, citys+M,cmp);



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

 {

     if(p_pre == citys[i].p)

     {

        number++;

     }

     else

     {

         number=1;

         p_pre = citys[i].p;

     }

     ids[citys[i].no] = id2String(citys[i].p)+id2String(number);

 }



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

 {

    cout<<ids[i]<<endl;

 }

 return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.3687045630031935x):
#include<bits/stdc++.h>

using namespace std;



int n,m;



struct az

{

	int p;

	int y;

	int cnt;

}q[100005];



struct za

{

	int p;

	int y;

    int x;

}l[100005];



bool cmp(za a, za b)

{

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

	return a.p < b.p;

}



int main()

{

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

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

	   scanf("%d%d",&q[i].p,&q[i].y),l[i].x=i,l[i].p=q[i].p,l[i].y=q[i].y;

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

	int now = 0 ;

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

	{

		if(l[i].p != l[i-1].p) now=0;

		q[l[i].x].cnt=++now;

	}

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

	{

		int s=q[i].p;

		int ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].p;

		s=q[i].cnt;

		ls=0;

		while(s)

		{

			s/=10;

			++ls;

		}

		for(int j=1;j<=6-ls;++j)

		   cout<<0;

		cout<<q[i].cnt;

		cout<<endl;

	}

	return 0;

 }