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

using namespace std;

#define THE using

#define DARK namespace

#define ONE std

#define dbg(x) cout << #x << " = " << x << endl



THE DARK ONE;

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

//    freopen("out.txt", "w", stdout);

//    freopen("input.txt", "r", stdin);

    vector<int> x(100005), y(100005), z[100005];

    int n, m;

    cin >> n >> m;

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

        cin >> x[i] >> y[i];

        z[x[i]].push_back(y[i]);

    }

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

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

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

        long long s = (long long) x[i] * 1000000;

        s += lower_bound(z[x[i]].begin(), z[x[i]].end(), y[i]) - z[x[i]].begin() + 1;

        printf("%012lld\n", s);

    }

    return 0;

}


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

using namespace std;

#define ff first

#define ss second

int main()

{

    int n,m;

    cin>>n>>m;

    vector<vector<int> > v(100000+3);



    vector<int>::iterator it;



    vector<pair<int,int> > vv;



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

    {

        int a, b;

        cin>>a>>b;

        v[a].push_back(b);

        vv.push_back(make_pair(a,b));

    }



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

    {

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

    }

    int sz = vv.size();

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

    {

        int x = vv[i].ff;

        int y = vv[i].ss;

        it = lower_bound(v[x].begin(),v[x].end(),y);



        int z = it-v[x].begin();

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

    }



    return 0;

}
// Slower C++ solution:


#include <iostream>

#include <cstdio>

#include <cmath>

#include <queue>

#include <map>

#include <cstring>

#include <string>

#include <set>

#include <vector>

#include <list>

#include <deque>

#include <algorithm>

#include <stack>

#include <numeric>

#include <time.h>

#include<iomanip>

#pragma warning(disable:4996)

using namespace std;

const int inf = 0x7f7f7f7f;

const long long mod = 1e9 + 7;

pair<int, int>q[120000];

set<int>p[120000];

map<int, int>a;

int main()

{

	int n, m;

	cin >> n >> m;

	set<int>::iterator iter;

	map<int, int>::iterator it;

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

	{

		cin >> q[i].first >> q[i].second;

		p[q[i].first].insert(q[i].second);

	}

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

	{

		int k = 1;

		for (iter = p[i].begin(); iter != p[i].end(); iter++)

			a[*iter] = k++;

	}

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

	{

		printf("%06d", q[i].first);

		it = a.find(q[i].second);

		printf("%06d\n", it->second);

	}

}

// 运行程序: Ctrl + F5 或调试 >“始执行(不调试)”菜单

// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示:

//   1. 使用解决方案资源管理器窗口添 加/管理文件

//   2. 使用团队资源管理器窗口连接到源代码管理

//   3. 使用输出窗口查看生成输出和其他消息

//   4. 使用错误列表窗口查看错误

//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目

//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件

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

using namespace std;

#define ff first

#define ss second

int main()

{

    int n,m;

    cin>>n>>m;

    vector<vector<int> > v(100000+3);



    vector<int>::iterator it;



    vector<pair<int,int> > vv;



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

    {

        int a, b;

        cin>>a>>b;

        v[a].push_back(b);

        vv.push_back(make_pair(a,b));

    }



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

    {

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

    }

    int sz = vv.size();

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

    {

        int x = vv[i].ff;

        int y = vv[i].ss;

        it = lower_bound(v[x].begin(),v[x].end(),y);



        int z = it-v[x].begin();

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

    }



    return 0;

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

using namespace std;

#define THE using

#define DARK namespace

#define ONE std

#define dbg(x) cout << #x << " = " << x << endl



THE DARK ONE;

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

//    freopen("out.txt", "w", stdout);

//    freopen("input.txt", "r", stdin);

    vector<int> x(100005), y(100005), z[100005];

    int n, m;

    cin >> n >> m;

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

        cin >> x[i] >> y[i];

        z[x[i]].push_back(y[i]);

    }

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

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

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

        long long s = (long long) x[i] * 1000000;

        s += lower_bound(z[x[i]].begin(), z[x[i]].end(), y[i]) - z[x[i]].begin() + 1;

        printf("%012lld\n", s);

    }

    return 0;

}


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

using namespace std;

#define cc(a) cout << a << endl;

#define msg(a,b) cout << a << " : " << b << endl;

#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;

#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;



string makeString(long long int n){

    stringstream ss;

    string str;

    ss << n;

    ss >> str;

    if(str.size() == 1){

        return "00000" + str;

    }else if(str.size() == 2){

        return "0000" + str;

    }else if(str.size() == 3){

        return "000" + str;

    }else if(str.size() == 4){

        return "00" + str;

    }else if(str.size() ==5){

        return "0" + str;

    }else if(str.size() == 6){

        return str;

    }



}



int main(){

    long long int n,m,a,b;

    string ans;

    vector< pair<long long int , long long int> > vec2;

    vector<long long int> vec[100004];

    map<pair<long long int, long long int> , string> mp;

    cin >> n >> m;

    while(m--){

        cin >> a >> b;

        vec[a].push_back(b);

        vec2.push_back(make_pair(a,b));

    }

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

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

    }

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

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

            ans = makeString(i) + makeString(j+1);

            mp[ make_pair(i, vec[i][j]) ] = ans;

        }

    }

    for(int i=0;i<vec2.size();i++){

        cout << mp[ make_pair( vec2[i].first, vec2[i].second ) ] << endl;

    }



    return 0;

}
// Slower C++ solution:


#include <iostream>

#include <cstdio>

#include <cmath>

#include <queue>

#include <map>

#include <cstring>

#include <string>

#include <set>

#include <vector>

#include <list>

#include <deque>

#include <algorithm>

#include <stack>

#include <numeric>

#include <time.h>

#include<iomanip>

#pragma warning(disable:4996)

using namespace std;

const int inf = 0x7f7f7f7f;

const long long mod = 1e9 + 7;

pair<int, int>q[120000];

set<int>p[120000];

map<int, int>a;

int main()

{

	int n, m;

	cin >> n >> m;

	set<int>::iterator iter;

	map<int, int>::iterator it;

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

	{

		cin >> q[i].first >> q[i].second;

		p[q[i].first].insert(q[i].second);

	}

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

	{

		int k = 1;

		for (iter = p[i].begin(); iter != p[i].end(); iter++)

			a[*iter] = k++;

	}

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

	{

		printf("%06d", q[i].first);

		it = a.find(q[i].second);

		printf("%06d\n", it->second);

	}

}

// 运行程序: Ctrl + F5 或调试 >“始执行(不调试)”菜单

// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示:

//   1. 使用解决方案资源管理器窗口添 加/管理文件

//   2. 使用团队资源管理器窗口连接到源代码管理

//   3. 使用输出窗口查看生成输出和其他消息

//   4. 使用错误列表窗口查看错误

//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目

//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件

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

using namespace std;

#define cc(a) cout << a << endl;

#define msg(a,b) cout << a << " : " << b << endl;

#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;

#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;



string makeString(long long int n){

    stringstream ss;

    string str;

    ss << n;

    ss >> str;

    if(str.size() == 1){

        return "00000" + str;

    }else if(str.size() == 2){

        return "0000" + str;

    }else if(str.size() == 3){

        return "000" + str;

    }else if(str.size() == 4){

        return "00" + str;

    }else if(str.size() ==5){

        return "0" + str;

    }else if(str.size() == 6){

        return str;

    }



}



int main(){

    long long int n,m,a,b;

    string ans;

    vector< pair<long long int , long long int> > vec2;

    vector<long long int> vec[100004];

    map<pair<long long int, long long int> , string> mp;

    cin >> n >> m;

    while(m--){

        cin >> a >> b;

        vec[a].push_back(b);

        vec2.push_back(make_pair(a,b));

    }

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

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

    }

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

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

            ans = makeString(i) + makeString(j+1);

            mp[ make_pair(i, vec[i][j]) ] = ans;

        }

    }

    for(int i=0;i<vec2.size();i++){

        cout << mp[ make_pair( vec2[i].first, vec2[i].second ) ] << endl;

    }



    return 0;

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

#include<iostream>

#include<algorithm>

#include<stack>

#include<cmath>

#include<vector>

using namespace std;

int n,m;

int p[100005]; 

int y[100005];

vector<int>v[100005];

int main(){

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

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

		scanf("%d%d",&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=1;i<=m;i++){

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

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

		printf("%06d\n",k);

	}

	return 0;

}

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

#include<algorithm>

using namespace std;

struct P{

	int p,y,d;

	int b[15];

};

int cmp(P x1,P x2){

	if(x1.p==x2.p){

		return x1.y<x2.y;

	}

	return x1.p<x2.p;

}

int cmp1(P x1,P x2){

	return x1.d<x2.d;

}

P a[100010];

int main(){

	int n,m,i,j,k;

	cin >> n >> m;

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

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

		a[i].d=i;

		for(j=0;j<13;j++){

			a[i].b[j]=0;

		}

	}

	sort(a,a+m,cmp);

	int x=1,w;

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

		if(i==0 || a[i].p!=a[i-1].p){

			x=1;

		}

		else{

			x++;

		}

		j=5;

		w=a[i].p;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==0)

				break;

			j--;

		}

		w=x;

		j=11;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==6)

				break;

			j--;

		}

	}

	sort(a,a+m,cmp1);

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

		for(j=0;j<12;j++){

			cout << a[i].b[j];

		}

		cout << endl;

	}

	return 0;

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

using namespace std;

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

const int MAX = 100005;

int P[MAX], Y[MAX];

vector<int> yd[MAX];

int main()

{

    int N, M;

    cin >> N >> M;

    rep(i, M)

    {

        cin >> 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("%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;

}


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

#include<algorithm>

using namespace std;

struct P{

	int p,y,d;

	int b[15];

};

int cmp(P x1,P x2){

	if(x1.p==x2.p){

		return x1.y<x2.y;

	}

	return x1.p<x2.p;

}

int cmp1(P x1,P x2){

	return x1.d<x2.d;

}

P a[100010];

int main(){

	int n,m,i,j,k;

	cin >> n >> m;

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

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

		a[i].d=i;

		for(j=0;j<13;j++){

			a[i].b[j]=0;

		}

	}

	sort(a,a+m,cmp);

	int x=1,w;

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

		if(i==0 || a[i].p!=a[i-1].p){

			x=1;

		}

		else{

			x++;

		}

		j=5;

		w=a[i].p;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==0)

				break;

			j--;

		}

		w=x;

		j=11;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==6)

				break;

			j--;

		}

	}

	sort(a,a+m,cmp1);

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

		for(j=0;j<12;j++){

			cout << a[i].b[j];

		}

		cout << endl;

	}

	return 0;

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

using namespace std;

#define THE using

#define DARK namespace

#define ONE std

#define dbg(x) cout << #x << " = " << x << endl



THE DARK ONE;

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

//    freopen("out.txt", "w", stdout);

//    freopen("input.txt", "r", stdin);

    vector<int> x(100005), y(100005), z[100005];

    int n, m;

    cin >> n >> m;

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

        cin >> x[i] >> y[i];

        z[x[i]].push_back(y[i]);

    }

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

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

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

        long long s = (long long) x[i] * 1000000;

        s += lower_bound(z[x[i]].begin(), z[x[i]].end(), y[i]) - z[x[i]].begin() + 1;

        printf("%012lld\n", s);

    }

    return 0;

}


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

#include<algorithm>

using namespace std;

struct P{

	int p,y,d;

	int b[15];

};

int cmp(P x1,P x2){

	if(x1.p==x2.p){

		return x1.y<x2.y;

	}

	return x1.p<x2.p;

}

int cmp1(P x1,P x2){

	return x1.d<x2.d;

}

P a[100010];

int main(){

	int n,m,i,j,k;

	cin >> n >> m;

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

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

		a[i].d=i;

		for(j=0;j<13;j++){

			a[i].b[j]=0;

		}

	}

	sort(a,a+m,cmp);

	int x=1,w;

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

		if(i==0 || a[i].p!=a[i-1].p){

			x=1;

		}

		else{

			x++;

		}

		j=5;

		w=a[i].p;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==0)

				break;

			j--;

		}

		w=x;

		j=11;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==6)

				break;

			j--;

		}

	}

	sort(a,a+m,cmp1);

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

		for(j=0;j<12;j++){

			cout << a[i].b[j];

		}

		cout << endl;

	}

	return 0;

}
// Slower C++ solution:


#include <iostream>

#include <cstdio>

#include <cmath>

#include <queue>

#include <map>

#include <cstring>

#include <string>

#include <set>

#include <vector>

#include <list>

#include <deque>

#include <algorithm>

#include <stack>

#include <numeric>

#include <time.h>

#include<iomanip>

#pragma warning(disable:4996)

using namespace std;

const int inf = 0x7f7f7f7f;

const long long mod = 1e9 + 7;

pair<int, int>q[120000];

set<int>p[120000];

map<int, int>a;

int main()

{

	int n, m;

	cin >> n >> m;

	set<int>::iterator iter;

	map<int, int>::iterator it;

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

	{

		cin >> q[i].first >> q[i].second;

		p[q[i].first].insert(q[i].second);

	}

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

	{

		int k = 1;

		for (iter = p[i].begin(); iter != p[i].end(); iter++)

			a[*iter] = k++;

	}

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

	{

		printf("%06d", q[i].first);

		it = a.find(q[i].second);

		printf("%06d\n", it->second);

	}

}

// 运行程序: Ctrl + F5 或调试 >“始执行(不调试)”菜单

// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示:

//   1. 使用解决方案资源管理器窗口添 加/管理文件

//   2. 使用团队资源管理器窗口连接到源代码管理

//   3. 使用输出窗口查看生成输出和其他消息

//   4. 使用错误列表窗口查看错误

//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目

//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件

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

#include<algorithm>

using namespace std;

struct P{

	int p,y,d;

	int b[15];

};

int cmp(P x1,P x2){

	if(x1.p==x2.p){

		return x1.y<x2.y;

	}

	return x1.p<x2.p;

}

int cmp1(P x1,P x2){

	return x1.d<x2.d;

}

P a[100010];

int main(){

	int n,m,i,j,k;

	cin >> n >> m;

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

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

		a[i].d=i;

		for(j=0;j<13;j++){

			a[i].b[j]=0;

		}

	}

	sort(a,a+m,cmp);

	int x=1,w;

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

		if(i==0 || a[i].p!=a[i-1].p){

			x=1;

		}

		else{

			x++;

		}

		j=5;

		w=a[i].p;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==0)

				break;

			j--;

		}

		w=x;

		j=11;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==6)

				break;

			j--;

		}

	}

	sort(a,a+m,cmp1);

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

		for(j=0;j<12;j++){

			cout << a[i].b[j];

		}

		cout << endl;

	}

	return 0;

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

using namespace std;

#define ff first

#define ss second

int main()

{

    int n,m;

    cin>>n>>m;

    vector<vector<int> > v(100000+3);



    vector<int>::iterator it;



    vector<pair<int,int> > vv;



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

    {

        int a, b;

        cin>>a>>b;

        v[a].push_back(b);

        vv.push_back(make_pair(a,b));

    }



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

    {

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

    }

    int sz = vv.size();

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

    {

        int x = vv[i].ff;

        int y = vv[i].ss;

        it = lower_bound(v[x].begin(),v[x].end(),y);



        int z = it-v[x].begin();

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

    }



    return 0;

}




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

#include<algorithm>

using namespace std;

struct P{

	int p,y,d;

	int b[15];

};

int cmp(P x1,P x2){

	if(x1.p==x2.p){

		return x1.y<x2.y;

	}

	return x1.p<x2.p;

}

int cmp1(P x1,P x2){

	return x1.d<x2.d;

}

P a[100010];

int main(){

	int n,m,i,j,k;

	cin >> n >> m;

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

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

		a[i].d=i;

		for(j=0;j<13;j++){

			a[i].b[j]=0;

		}

	}

	sort(a,a+m,cmp);

	int x=1,w;

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

		if(i==0 || a[i].p!=a[i-1].p){

			x=1;

		}

		else{

			x++;

		}

		j=5;

		w=a[i].p;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==0)

				break;

			j--;

		}

		w=x;

		j=11;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==6)

				break;

			j--;

		}

	}

	sort(a,a+m,cmp1);

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

		for(j=0;j<12;j++){

			cout << a[i].b[j];

		}

		cout << endl;

	}

	return 0;

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

using namespace std;

#define cc(a) cout << a << endl;

#define msg(a,b) cout << a << " : " << b << endl;

#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;

#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;



string makeString(long long int n){

    stringstream ss;

    string str;

    ss << n;

    ss >> str;

    if(str.size() == 1){

        return "00000" + str;

    }else if(str.size() == 2){

        return "0000" + str;

    }else if(str.size() == 3){

        return "000" + str;

    }else if(str.size() == 4){

        return "00" + str;

    }else if(str.size() ==5){

        return "0" + str;

    }else if(str.size() == 6){

        return str;

    }



}



int main(){

    long long int n,m,a,b;

    string ans;

    vector< pair<long long int , long long int> > vec2;

    vector<long long int> vec[100004];

    map<pair<long long int, long long int> , string> mp;

    cin >> n >> m;

    while(m--){

        cin >> a >> b;

        vec[a].push_back(b);

        vec2.push_back(make_pair(a,b));

    }

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

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

    }

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

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

            ans = makeString(i) + makeString(j+1);

            mp[ make_pair(i, vec[i][j]) ] = ans;

        }

    }

    for(int i=0;i<vec2.size();i++){

        cout << mp[ make_pair( vec2[i].first, vec2[i].second ) ] << endl;

    }



    return 0;

}


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

#include<algorithm>

using namespace std;

struct P{

	int p,y,d;

	int b[15];

};

int cmp(P x1,P x2){

	if(x1.p==x2.p){

		return x1.y<x2.y;

	}

	return x1.p<x2.p;

}

int cmp1(P x1,P x2){

	return x1.d<x2.d;

}

P a[100010];

int main(){

	int n,m,i,j,k;

	cin >> n >> m;

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

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

		a[i].d=i;

		for(j=0;j<13;j++){

			a[i].b[j]=0;

		}

	}

	sort(a,a+m,cmp);

	int x=1,w;

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

		if(i==0 || a[i].p!=a[i-1].p){

			x=1;

		}

		else{

			x++;

		}

		j=5;

		w=a[i].p;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==0)

				break;

			j--;

		}

		w=x;

		j=11;

		while(w){

			a[i].b[j]=w%10;

			w/=10;

			if(j==6)

				break;

			j--;

		}

	}

	sort(a,a+m,cmp1);

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

		for(j=0;j<12;j++){

			cout << a[i].b[j];

		}

		cout << endl;

	}

	return 0;

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

using namespace std;

#define THE using

#define DARK namespace

#define ONE std

#define dbg(x) cout << #x << " = " << x << endl



THE DARK ONE;

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

//    freopen("out.txt", "w", stdout);

//    freopen("input.txt", "r", stdin);

    vector<int> x(100005), y(100005), z[100005];

    int n, m;

    cin >> n >> m;

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

        cin >> x[i] >> y[i];

        z[x[i]].push_back(y[i]);

    }

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

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

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

        long long s = (long long) x[i] * 1000000;

        s += lower_bound(z[x[i]].begin(), z[x[i]].end(), y[i]) - z[x[i]].begin() + 1;

        printf("%012lld\n", s);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.251627937405205x):
#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;

}
// Slower C++ solution:


#include <iostream>

#include <cstdio>

#include <cmath>

#include <queue>

#include <map>

#include <cstring>

#include <string>

#include <set>

#include <vector>

#include <list>

#include <deque>

#include <algorithm>

#include <stack>

#include <numeric>

#include <time.h>

#include<iomanip>

#pragma warning(disable:4996)

using namespace std;

const int inf = 0x7f7f7f7f;

const long long mod = 1e9 + 7;

pair<int, int>q[120000];

set<int>p[120000];

map<int, int>a;

int main()

{

	int n, m;

	cin >> n >> m;

	set<int>::iterator iter;

	map<int, int>::iterator it;

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

	{

		cin >> q[i].first >> q[i].second;

		p[q[i].first].insert(q[i].second);

	}

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

	{

		int k = 1;

		for (iter = p[i].begin(); iter != p[i].end(); iter++)

			a[*iter] = k++;

	}

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

	{

		printf("%06d", q[i].first);

		it = a.find(q[i].second);

		printf("%06d\n", it->second);

	}

}

// 运行程序: Ctrl + F5 或调试 >“始执行(不调试)”菜单

// 调试程序: F5 或调试 >“开始调试”菜单

// 入门提示:

//   1. 使用解决方案资源管理器窗口添 加/管理文件

//   2. 使用团队资源管理器窗口连接到源代码管理

//   3. 使用输出窗口查看生成输出和其他消息

//   4. 使用错误列表窗口查看错误

//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目

//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件

// Faster C++ solution for the same problem (measured speedup: 2.1193797817738904x):
#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;

}