stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



struct str

{

    ll i,y,p;

};

bool operator<(str a,str b)

{

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

    return a.p<b.p;

}



string make(ll n)

{



    string st,st1;

    while(n!=0)

    {

        int a=n%10;

        st.push_back(a+48);

        n/=10;

    }

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

    int i,diff=6-st.size();

    for(i=0; i<diff; i++)st1.push_back('0');

    for(i=0; i<st.size(); i++)st1.push_back(st[i]);

    return st1;

}



int main()

{



    ll n,a,b,m,i,c,y,p,pos;

    vector<str>v;

    string st[100007];

    cin >> n >> m;

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

    {

        cin >> a >> b;

        v.push_back({i+1,b,a});

    }

    sort(v.begin(),v.end());

    map<int,int>mp;

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

    {

        pos=v[i].i;

        p=v[i].p;

        y=v[i].y;

        mp[p]++;

        a=mp[p];

        st[pos]=make(p)+make(a);

    }

    for(i=1; i<=m; i++)cout << st[i] << "\n";







    return 0;

}




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

using namespace std;

const int maxn = 1e5 + 5;

struct node{

	int x,y;

	int num,pre;

}rec[maxn],nxt[maxn];

bool cmp(node a,node b){

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

	return a.x < b.x; 

} 

bool bmp(node a,node b){

	return a.num < b.num; 

} 

int main(){

	int n,m;

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

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

		int x,y;

		scanf("%d %d",&x,&y);

		rec[i].x = x;

		rec[i].y = y;

		rec[i].num = i;

	}

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

	int idx = 1;

	int t = rec[1].x;

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

		if(rec[i].x != t){

			t = rec[i].x;

			idx = 1;

			rec[i].pre = idx;

			idx++;

		}

		else{

			rec[i].pre = idx;

			idx++;

		}

	}

	sort(rec+1,rec+1+m,bmp);

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

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

	}

	return 0;

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

#include<cstdio>

#include<queue>

#include<algorithm>

using namespace std;



const int maxn = 1e5 + 10;

vector <int> g[maxn];

int num[maxn], num1[maxn];

int main(){

	int n, m;

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

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

		int a, b;

		scanf("%d %d", &a, &b);

		g[a].push_back(b);

		num[i] = a;

		num1[i] = b;

	}

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

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

	}

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

		int y = num1[i], z = num[i];

		int x = upper_bound(g[z].begin(), g[z].end(), y) - g[z].begin();

		printf("%06d%06d\n", z, x);

	}

	return 0;

}//1212232123

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

using namespace std;

const int maxn = 1e5 + 5;

struct node{

	int x,y;

	int num,pre;

}rec[maxn],nxt[maxn];

bool cmp(node a,node b){

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

	return a.x < b.x; 

} 

bool bmp(node a,node b){

	return a.num < b.num; 

} 

int main(){

	int n,m;

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

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

		int x,y;

		scanf("%d %d",&x,&y);

		rec[i].x = x;

		rec[i].y = y;

		rec[i].num = i;

	}

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

	int idx = 1;

	int t = rec[1].x;

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

		if(rec[i].x != t){

			t = rec[i].x;

			idx = 1;

			rec[i].pre = idx;

			idx++;

		}

		else{

			rec[i].pre = idx;

			idx++;

		}

	}

	sort(rec+1,rec+1+m,bmp);

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

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

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

vector<int>v[MAXN];

int main()

{

	int n,m;

	cin >> n >> m;

	int a[m][2];

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

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

		v[a[i][0]].push_back(a[i][1]);

	}

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

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

	}

	vector<int>::iterator it;

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

		it = find(v[a[i][0]].begin(),v[a[i][0]].end(),a[i][1]);

		printf("%06d%06d\n",a[i][0],upper_bound(v[a[i][0]].begin(), v[a[i][0]].end(), a[i][1]) - v[a[i][0]].begin());

	}

	return 0;

}


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

using namespace std;

const int maxn = 1e5 + 5;

struct node{

	int x,y;

	int num,pre;

}rec[maxn],nxt[maxn];

bool cmp(node a,node b){

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

	return a.x < b.x; 

} 

bool bmp(node a,node b){

	return a.num < b.num; 

} 

int main(){

	int n,m;

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

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

		int x,y;

		scanf("%d %d",&x,&y);

		rec[i].x = x;

		rec[i].y = y;

		rec[i].num = i;

	}

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

	int idx = 1;

	int t = rec[1].x;

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

		if(rec[i].x != t){

			t = rec[i].x;

			idx = 1;

			rec[i].pre = idx;

			idx++;

		}

		else{

			rec[i].pre = idx;

			idx++;

		}

	}

	sort(rec+1,rec+1+m,bmp);

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

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

	}

	return 0;

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

#include <algorithm>

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include <string.h>

#include <queue>

using namespace std;



struct A

{

    long long ct;

    long long num;

    long long id;

    long long sc;

} a[100005];



bool cmp(A a,A b)

{

    if(a.ct==b.ct)

        return a.num<b.num;

    return a.ct<b.ct;

}



bool cmp2(A a,A b)

{

    return a.sc<b.sc;

}



long long c[100010];



int main()

{

    long long n,m;

    long long i,j;

    while(scanf("%lld%lld",&n,&m)!=EOF)

    {

        memset(c,0,sizeof(c));

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

        {

            scanf("%lld%lld",&a[i].ct,&a[i].num);

            a[i].sc=i+1;

        }

        sort(a,a+m,cmp);

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

        {

            a[j].id=1+c[a[j].ct];

            c[a[j].ct]++;

        }

        sort(a,a+m,cmp2);

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

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

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.849850260875698x):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<cmath>

#include<algorithm>

#include<vector>

using namespace std;

const int N = 1e5 + 5;

struct node{

    int flag,num,ii,mm;

};

node a1[N],a2[N],vis[N]={0};

int cmp(node x,node y){

    if(x.flag!=y.flag) return x.flag<y.flag;

    return x.num<y.num;

}

int cmp1(node x,node y){

    return x.ii<y.ii;

}

int main()

{

    int n,m;

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

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

        scanf("%d %d",&a1[i].flag,&a1[i].num);

        a2[i].ii=i;

        a2[i].flag=a1[i].flag;

        a2[i].num=a1[i].num;

    }

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

    int f=a2[1].flag,ans=1;

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

        if(f==a2[i].flag){

            a2[i].mm=ans++;

        }

        else{

            f=a2[i].flag;

            ans=1;

            a2[i].mm=ans++;



        }

    }

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

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

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

    }

    return 0;

}

/*

2 4

2 3

3 4

2 1

3 5

*/
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



struct str

{

    ll i,y,p;

};

bool operator<(str a,str b)

{

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

    return a.p<b.p;

}



string make(ll n)

{



    string st,st1;

    while(n!=0)

    {

        int a=n%10;

        st.push_back(a+48);

        n/=10;

    }

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

    int i,diff=6-st.size();

    for(i=0; i<diff; i++)st1.push_back('0');

    for(i=0; i<st.size(); i++)st1.push_back(st[i]);

    return st1;

}



int main()

{



    ll n,a,b,m,i,c,y,p,pos;

    vector<str>v;

    string st[100007];

    cin >> n >> m;

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

    {

        cin >> a >> b;

        v.push_back({i+1,b,a});

    }

    sort(v.begin(),v.end());

    map<int,int>mp;

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

    {

        pos=v[i].i;

        p=v[i].p;

        y=v[i].y;

        mp[p]++;

        a=mp[p];

        st[pos]=make(p)+make(a);

    }

    for(i=1; i<=m; i++)cout << st[i] << "\n";







    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 4.414949008426139x):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<cmath>

#include<algorithm>

#include<vector>

using namespace std;

const int N = 1e5 + 5;

struct node{

    int flag,num,ii,mm;

};

node a1[N],a2[N],vis[N]={0};

int cmp(node x,node y){

    if(x.flag!=y.flag) return x.flag<y.flag;

    return x.num<y.num;

}

int cmp1(node x,node y){

    return x.ii<y.ii;

}

int main()

{

    int n,m;

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

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

        scanf("%d %d",&a1[i].flag,&a1[i].num);

        a2[i].ii=i;

        a2[i].flag=a1[i].flag;

        a2[i].num=a1[i].num;

    }

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

    int f=a2[1].flag,ans=1;

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

        if(f==a2[i].flag){

            a2[i].mm=ans++;

        }

        else{

            f=a2[i].flag;

            ans=1;

            a2[i].mm=ans++;



        }

    }

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

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

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

    }

    return 0;

}

/*

2 4

2 3

3 4

2 1

3 5

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

#include<cstdio>

#include<queue>

#include<algorithm>

using namespace std;



const int maxn = 1e5 + 10;

vector <int> g[maxn];

int num[maxn], num1[maxn];

int main(){

	int n, m;

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

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

		int a, b;

		scanf("%d %d", &a, &b);

		g[a].push_back(b);

		num[i] = a;

		num1[i] = b;

	}

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

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

	}

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

		int y = num1[i], z = num[i];

		int x = upper_bound(g[z].begin(), g[z].end(), y) - g[z].begin();

		printf("%06d%06d\n", z, x);

	}

	return 0;

}//1212232123

// Faster C++ solution for the same problem (measured speedup: 3.5303944011281834x):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<cmath>

#include<algorithm>

#include<vector>

using namespace std;

const int N = 1e5 + 5;

struct node{

    int flag,num,ii,mm;

};

node a1[N],a2[N],vis[N]={0};

int cmp(node x,node y){

    if(x.flag!=y.flag) return x.flag<y.flag;

    return x.num<y.num;

}

int cmp1(node x,node y){

    return x.ii<y.ii;

}

int main()

{

    int n,m;

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

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

        scanf("%d %d",&a1[i].flag,&a1[i].num);

        a2[i].ii=i;

        a2[i].flag=a1[i].flag;

        a2[i].num=a1[i].num;

    }

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

    int f=a2[1].flag,ans=1;

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

        if(f==a2[i].flag){

            a2[i].mm=ans++;

        }

        else{

            f=a2[i].flag;

            ans=1;

            a2[i].mm=ans++;



        }

    }

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

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

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

    }

    return 0;

}

/*

2 4

2 3

3 4

2 1

3 5

*/
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

vector<int>v[MAXN];

int main()

{

	int n,m;

	cin >> n >> m;

	int a[m][2];

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

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

		v[a[i][0]].push_back(a[i][1]);

	}

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

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

	}

	vector<int>::iterator it;

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

		it = find(v[a[i][0]].begin(),v[a[i][0]].end(),a[i][1]);

		printf("%06d%06d\n",a[i][0],upper_bound(v[a[i][0]].begin(), v[a[i][0]].end(), a[i][1]) - v[a[i][0]].begin());

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.5343911437002546x):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<cmath>

#include<algorithm>

#include<vector>

using namespace std;

const int N = 1e5 + 5;

struct node{

    int flag,num,ii,mm;

};

node a1[N],a2[N],vis[N]={0};

int cmp(node x,node y){

    if(x.flag!=y.flag) return x.flag<y.flag;

    return x.num<y.num;

}

int cmp1(node x,node y){

    return x.ii<y.ii;

}

int main()

{

    int n,m;

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

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

        scanf("%d %d",&a1[i].flag,&a1[i].num);

        a2[i].ii=i;

        a2[i].flag=a1[i].flag;

        a2[i].num=a1[i].num;

    }

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

    int f=a2[1].flag,ans=1;

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

        if(f==a2[i].flag){

            a2[i].mm=ans++;

        }

        else{

            f=a2[i].flag;

            ans=1;

            a2[i].mm=ans++;



        }

    }

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

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

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

    }

    return 0;

}

/*

2 4

2 3

3 4

2 1

3 5

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

#include <algorithm>

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include <string.h>

#include <queue>

using namespace std;



struct A

{

    long long ct;

    long long num;

    long long id;

    long long sc;

} a[100005];



bool cmp(A a,A b)

{

    if(a.ct==b.ct)

        return a.num<b.num;

    return a.ct<b.ct;

}



bool cmp2(A a,A b)

{

    return a.sc<b.sc;

}



long long c[100010];



int main()

{

    long long n,m;

    long long i,j;

    while(scanf("%lld%lld",&n,&m)!=EOF)

    {

        memset(c,0,sizeof(c));

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

        {

            scanf("%lld%lld",&a[i].ct,&a[i].num);

            a[i].sc=i+1;

        }

        sort(a,a+m,cmp);

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

        {

            a[j].id=1+c[a[j].ct];

            c[a[j].ct]++;

        }

        sort(a,a+m,cmp2);

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

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

    }

    return 0;

}


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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define U (LL)0

#define endl "\n"

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

map<pair<LL,LL>,LL> v;

map<pair<LL,LL>,pair<LL,LL> >x;

map<LL,LL>w;

V< pair<LL,LL> >u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    string a;

    cin>>m>>n;

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

    {

        cin>>m>>o;

        u.PSB({m,o});

        v[{o,m}]=1;

    }

    for(map<pair<LL,LL>,LL> :: iterator it=v.B; it!=v.E; it++)

    {

        p=it->FI.SE;

        q=it->FI.FI;

        k=w[p]+1;

        w[p]++;

        x[ {p,q}]= {p,k};

    }

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

    {

        p=x[{u[i].FI,u[i].SE}].FI;

        q=x[{u[i].FI,u[i].SE}].SE;

        s=0;

        k=p;

        while(k)

        {

            s++;

            k/=10;

        }

        t=0;

        k=q;

        while(k)

        {

            t++;

            k/=10;

        }

        for(j=0;j<6-s;j++)

        {

            cout<<0;

        }

        cout<<p;

         for(j=0;j<6-t;j++)

        {

            cout<<0;

        }

        cout<<q<<endl;

    }



    return 0;



}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



struct str

{

    ll i,y,p;

};

bool operator<(str a,str b)

{

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

    return a.p<b.p;

}



string make(ll n)

{



    string st,st1;

    while(n!=0)

    {

        int a=n%10;

        st.push_back(a+48);

        n/=10;

    }

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

    int i,diff=6-st.size();

    for(i=0; i<diff; i++)st1.push_back('0');

    for(i=0; i<st.size(); i++)st1.push_back(st[i]);

    return st1;

}



int main()

{



    ll n,a,b,m,i,c,y,p,pos;

    vector<str>v;

    string st[100007];

    cin >> n >> m;

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

    {

        cin >> a >> b;

        v.push_back({i+1,b,a});

    }

    sort(v.begin(),v.end());

    map<int,int>mp;

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

    {

        pos=v[i].i;

        p=v[i].p;

        y=v[i].y;

        mp[p]++;

        a=mp[p];

        st[pos]=make(p)+make(a);

    }

    for(i=1; i<=m; i++)cout << st[i] << "\n";







    return 0;

}




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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define U (LL)0

#define endl "\n"

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

map<pair<LL,LL>,LL> v;

map<pair<LL,LL>,pair<LL,LL> >x;

map<LL,LL>w;

V< pair<LL,LL> >u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    string a;

    cin>>m>>n;

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

    {

        cin>>m>>o;

        u.PSB({m,o});

        v[{o,m}]=1;

    }

    for(map<pair<LL,LL>,LL> :: iterator it=v.B; it!=v.E; it++)

    {

        p=it->FI.SE;

        q=it->FI.FI;

        k=w[p]+1;

        w[p]++;

        x[ {p,q}]= {p,k};

    }

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

    {

        p=x[{u[i].FI,u[i].SE}].FI;

        q=x[{u[i].FI,u[i].SE}].SE;

        s=0;

        k=p;

        while(k)

        {

            s++;

            k/=10;

        }

        t=0;

        k=q;

        while(k)

        {

            t++;

            k/=10;

        }

        for(j=0;j<6-s;j++)

        {

            cout<<0;

        }

        cout<<p;

         for(j=0;j<6-t;j++)

        {

            cout<<0;

        }

        cout<<q<<endl;

    }



    return 0;



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

#include<cstdio>

#include<queue>

#include<algorithm>

using namespace std;



const int maxn = 1e5 + 10;

vector <int> g[maxn];

int num[maxn], num1[maxn];

int main(){

	int n, m;

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

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

		int a, b;

		scanf("%d %d", &a, &b);

		g[a].push_back(b);

		num[i] = a;

		num1[i] = b;

	}

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

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

	}

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

		int y = num1[i], z = num[i];

		int x = upper_bound(g[z].begin(), g[z].end(), y) - g[z].begin();

		printf("%06d%06d\n", z, x);

	}

	return 0;

}//1212232123

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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define U (LL)0

#define endl "\n"

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

map<pair<LL,LL>,LL> v;

map<pair<LL,LL>,pair<LL,LL> >x;

map<LL,LL>w;

V< pair<LL,LL> >u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    string a;

    cin>>m>>n;

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

    {

        cin>>m>>o;

        u.PSB({m,o});

        v[{o,m}]=1;

    }

    for(map<pair<LL,LL>,LL> :: iterator it=v.B; it!=v.E; it++)

    {

        p=it->FI.SE;

        q=it->FI.FI;

        k=w[p]+1;

        w[p]++;

        x[ {p,q}]= {p,k};

    }

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

    {

        p=x[{u[i].FI,u[i].SE}].FI;

        q=x[{u[i].FI,u[i].SE}].SE;

        s=0;

        k=p;

        while(k)

        {

            s++;

            k/=10;

        }

        t=0;

        k=q;

        while(k)

        {

            t++;

            k/=10;

        }

        for(j=0;j<6-s;j++)

        {

            cout<<0;

        }

        cout<<p;

         for(j=0;j<6-t;j++)

        {

            cout<<0;

        }

        cout<<q<<endl;

    }



    return 0;



}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

vector<int>v[MAXN];

int main()

{

	int n,m;

	cin >> n >> m;

	int a[m][2];

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

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

		v[a[i][0]].push_back(a[i][1]);

	}

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

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

	}

	vector<int>::iterator it;

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

		it = find(v[a[i][0]].begin(),v[a[i][0]].end(),a[i][1]);

		printf("%06d%06d\n",a[i][0],upper_bound(v[a[i][0]].begin(), v[a[i][0]].end(), a[i][1]) - v[a[i][0]].begin());

	}

	return 0;

}


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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator sl

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define U (LL)0

#define endl "\n"

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

map<pair<LL,LL>,LL> v;

map<pair<LL,LL>,pair<LL,LL> >x;

map<LL,LL>w;

V< pair<LL,LL> >u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z;

    string a;

    cin>>m>>n;

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

    {

        cin>>m>>o;

        u.PSB({m,o});

        v[{o,m}]=1;

    }

    for(map<pair<LL,LL>,LL> :: iterator it=v.B; it!=v.E; it++)

    {

        p=it->FI.SE;

        q=it->FI.FI;

        k=w[p]+1;

        w[p]++;

        x[ {p,q}]= {p,k};

    }

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

    {

        p=x[{u[i].FI,u[i].SE}].FI;

        q=x[{u[i].FI,u[i].SE}].SE;

        s=0;

        k=p;

        while(k)

        {

            s++;

            k/=10;

        }

        t=0;

        k=q;

        while(k)

        {

            t++;

            k/=10;

        }

        for(j=0;j<6-s;j++)

        {

            cout<<0;

        }

        cout<<p;

         for(j=0;j<6-t;j++)

        {

            cout<<0;

        }

        cout<<q<<endl;

    }



    return 0;



}