stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

}




// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

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

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N, M;

	cin >> N >> M;

	map<int, int> MAP[100001];

	rep1(i, M) {

		int P, Y;

		cin >> P >> Y;

		MAP[P][Y] = i;

	}



	int kotae1[100001], kotae2[100001];

	rep1(i, N) {

		int kari = 1;

		for (auto itr : MAP[i]) {

			kotae1[itr.second] = i;

			kotae2[itr.second] = kari;

			kari++;

		}

	}



	rep1(i, M) {

		cout << setfill('0') << setw(6) << kotae1[i] << setw(6) << kotae2[i] << "\n";

	}



	Would you please return 0;

}

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

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}

const int dm = 1 << 21;

char dn[dm], * di = dn;

inline void putkotae(int X, int Y) {

	char C[12];

	rep(i, 6) {

		*(C + i) = '0' + Y % 10;

		Y /= 10;

	}

	rep(i, 6) {

		*(C + i + 6) = '0' + X % 10;

		X /= 10;

	}

	for (int i = 11; i >= 0; i--)* di++ = (*(C + i));

	*di++ = '\n';

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N = getint(), M = getint();

	int P[100000], PK[100001] = {};

	ll S[100000];

	rep(i, M) {

		P[i] = getint();

		S[i] = ((ll)getint() << 20) + i;

	}

	sort(S, S + M);



	int kotae[100000];

	rep(i, M) {

		int j = S[i] & 131071;

		kotae[j] = ++PK[P[j]];

	}

	rep(i, M) putkotae(P[i], kotae[i]);



	fwrite_unlocked(dn, di - dn, 1, stdout);



	Would you please return 0;

}

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

using namespace std;

typedef long long ll;



int n,m;

int p[100001],y[100001];

vector<int> city[100001]; 



int main()

{

    cin >> n >> m;

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

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

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

    }



    for(int i = 0; i < n; i++) sort(city[i+1].begin(),city[i+1].end());



    for(int i = 0; i < m; i++) printf("%012lld\n",ll(p[i])*1000000+int(lower_bound(city[p[i]].begin(),city[p[i]].end(),y[i])-city[p[i]].begin()+1));



    return 0;

}

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

using namespace std;



typedef long long ll;

typedef pair<int,int> P;



const int INF = 1e9;

const int mod = 1e9+7;



int main()

{

    int n,m;

    cin >> n >> m;

    vector<int> pm[n],p(m),y(m);



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

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

        pm[p[i]-1].push_back(y[i]);

    }



    for(int i = 0; i < n; i++) sort(pm[i].begin(),pm[i].end());

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

        printf("%06d%06d\n",p[i],lower_bound(pm[p[i]-1].begin(),pm[p[i]-1].end(),y[i])-pm[p[i]-1].begin()+1); 

    }

}

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

using namespace std;

 

int main() {

  int n,m;

  cin >> n>>m;

  vector<int> p(100010);

  vector<int> y(100010);

  vector<vector<int>>id(100010);

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

    cin >> p.at(i)>>y.at(i);

    id.at(p.at(i)-1).push_back(y.at(i));

  }

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

    sort(id.at(i).begin(),id.at(i).end());

  }

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

    printf("%06d",p.at(i));

    auto itr = lower_bound(id.at(p.at(i)-1).begin(),id.at(p.at(i)-1).end(),y.at(i));

    printf("%06d", itr-id.at(p.at(i)-1).begin()+1);

    cout <<endl;

  }

}

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

using namespace std;

typedef long long ll;

#define inf 1000000007

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





int main() {

	ll p,c,P[100010],C[100010];

	cin>>p>>c;

	vector<int>a[100010];

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

		int x,y;

		cin>>x>>y;

		x--;

		P[i]=x;C[i]=y;

		a[x].push_back(y);

	}

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

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

	}

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

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

		auto itr=lower_bound(ALL(a[P[i]]),C[i]);

		printf("%06d\n",itr-a[P[i]].begin()+1);

	}

	return 0;

}

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

#include <string>

#include <vector>

#include <set>

#include <map>

#include <iomanip>

#include <cmath>

#include <algorithm>

#include <iomanip>

#include <queue>

using ll = long long;

using namespace std;



int const MOD = 1e9 + 7;

int arr[100010];

int main(void)

{

    int N, M;

    cin >> N >> M;



    map<int, int> m1;

    map<int, int> m2;

    vector<pair<int, int>> vp;

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

    {

        int p, y;

        cin >> p >> y;

        vp.push_back({p, y});

        m1[y] = p;

    }

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

        arr[i] = 0;

    for (auto itr = m1.begin(); itr != m1.end(); ++itr)

    {

        m2[(*itr).first] = arr[(*itr).second] + 1;

        arr[(*itr).second]++;

    }



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

    {

        cout << setw(6) << setfill('0') << m1[vp[i].second];

        cout << setw(6) << setfill('0') << m2[vp[i].second];

        cout << endl;

    }

    return 0;

}

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

#include <climits>

#include <iostream>

#include <string>

#include <vector>

#include <set>

#include <cmath>

#include <stack>

#include <algorithm>

#include <iomanip>

#include <map>

#include <queue>

#include <functional>

#include <numeric>

#include <chrono>

#include <cstdlib>

using ll = long long;

using namespace std;



const ll MOD = 1e9 + 7;

const double pi = acos(-1);

typedef pair<int, int> P;

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

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

#define EPS 1e-4

#define OUTPUT(i) (cout << (ll)i << endl)

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



bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)

{



    if (a.first == b.first)

        return a.second < b.second;



    return a.first < b.first;

}



ll gcd(ll a, ll b)

{

    if (b == 0)

        return a;

    return gcd(b, a % b);

}

vector<ll> v;



struct C

{

    ll x, y, h;

};

int elem[100010];

int main()

{

    cin.tie(0);

    ios::sync_with_stdio(false);



    //cout << fixed << setprecision(15);



    int N, M;

    cin >> N >> M;

    vector<pair<int, int>> vp;

    map<int, int> mp;

    REP(i, M)

    {

        int P, Y;

        cin >> P >> Y;

        vp.push_back(make_pair(P, Y));

        mp[Y] = P;

    }



    map<int, int> mp2;

    for (auto e : mp)

    {

        mp2[e.first] = ++elem[e.second];

        //cout << mp[e.first] << endl;

    }



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

    {

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

        cout << setfill('0') << std::right << setw(6) << mp2[vp[i].second] << endl;

    }

    return 0;

}


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

#include <vector>

#include <algorithm>

using namespace std;



int main() {

    int n, m;

    int p[100000], y[100000];

    vector<int> yd[100001];

    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++) {

        auto itr = lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]);

        string s1 = to_string(p[i]);

        string s2 = to_string(itr - yd[p[i]].begin() + 1);

        string t1(6 - s1.length(), '0');

        string t2(6 - s2.length(), '0');

        string ans = t1 + s1 + t2 + s2;

        cout << ans << endl;

    }

    return 0;

}

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

#include <vector>

#include <algorithm>

using namespace std;



typedef pair<int, int> P;

typedef pair<P, int> PP;



int main() {

    int N, M;

    cin >> N >> M;

    vector<PP> C(M);

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

        int p, y;

        cin >> p >> y;

        C[i] = PP(P(p, y), i);

    }



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

    vector<P> res(M);

    int cnt = 0, pre = 0;

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

        P c = C[i].first;

        if (c.first == pre) {

            cnt++;

        } else {

            cnt = 1;

        }

        pre = c.first;



        res[C[i].second] = P(pre, cnt);

    }



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

        printf("%.6d%.6d\n", res[i].first, res[i].second);

    }

    return 0;

}

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

#include <vector>

#include <algorithm>

#include <climits>

#include <iomanip>



using namespace std;



vector <int> ans[100001];



int main(){

    int N, M;

    cin >> N >> M;

    vector <int> P, Y;

    

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

        int sub;

        cin >> sub;

        P.push_back(sub);

        cin >> sub;

        Y.push_back(sub);

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

    }



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

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

    }

    

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

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

        cout << setfill('0') << setw(6) << int(lower_bound(ans[P[i]].begin(), ans[P[i]].end(), Y[i]) - ans[P[i]].begin()) + 1 << "\n";

    }

}

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

#include <vector>

#include <algorithm>

#include <cmath>

#include <queue>

#include <string>

#include <map>

#include <set>

#include <stack>

#include <tuple>

#include <deque>

#include <numeric>

#include <bitset>

#include <iomanip>

#include <cassert>

#include <chrono>

#include <random>

#include <limits>

#include <iterator>

#include <functional>

#include <sstream>

#include <complex>

using namespace std;



typedef long long ll;

typedef uint64_t ull;

typedef pair<int, int> P;

constexpr double PI = 3.1415926535897932;   // acos(-1)

constexpr double EPS = 1e-9;

constexpr int INF = 1001001001;

constexpr int mod = 1000000007;

// constexpr int mod = 998244353;



#define chmax(x, y) x = max(x, y)

#define chmin(x, y) x = min(x, y)



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int n, m;

    cin >> n >> m;

    vector<vector<P>> input(n + 1);

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

        int p, y;

        cin >> p >> y;

        input[p].push_back(P(y, i));

    }

    for(int i = 1; i <= n; ++i) sort(input[i].begin(), input[i].end());

    vector<ll> ans(m, 0);

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

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

        for(int j = 0; j < sz; ++j){

            int y = input[i][j].first, id = input[i][j].second;

            ans[id] += (ll)i * 1000000;

            ans[id] += j + 1;

        }

    }

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

        cout << setfill('0') << right << setw(12);

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

    }

}

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

#include <string>

#include <vector>

#include <algorithm>



using namespace std;



int main(){

  int N, M;

  cin >> N >> M;

  vector<pair<int, int> > P[100010];

  string s[100010];

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

    int p, y;

    cin >> p >> y;

    P[p].emplace_back(make_pair(y,i));

  }

  for(int i=1; i<=N; i++) sort(P[i].begin(), P[i].end());

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

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

      for(int k=0; k<6-to_string(i).size(); k++) s[P[i][j].second]+='0';

      s[P[i][j].second]+=to_string(i);

      for(int k=0; k<6-to_string(j+1).size(); k++) s[P[i][j].second]+='0';

      s[P[i][j].second]+=to_string(j+1);

    }

  }

  for(int i=1; i<=M; i++) cout << s[i] << endl;

  

  return 0;

}

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

#include <iomanip>

#include <string>

#include <vector>

#include <algorithm>



using namespace std;



int main(){

  int N, M;

  cin >> N >> M;

  vector<pair<int, int> > P[100010];

  int s1[100010];

  int s2[100010];

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

    int p, y;

    cin >> p >> y;

    P[p].emplace_back(make_pair(y,i));

  }

  for(int i=1; i<=N; i++) sort(P[i].begin(), P[i].end());

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

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

      s1[P[i][j].second]=i;

      s2[P[i][j].second]=j+1;

    }

  }

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

    cout.fill('0');

    cout << setw(6) << s1[i];

    cout << setw(6) << s2[i] << endl;

  }

  

  return 0;

}

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

using namespace std;

typedef pair<int,int> A;

#define int long long

int N,M;

pair<int , int> K[100001];

signed main() {

    cin >> N >> M;

    vector<A>vec[100001];

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

        int P,Y;

        cin >> P >> Y;

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

    }

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

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

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

        	K[vec[i][j].second].first = i;

       	    K[vec[i][j].second].second = j+1;

        }

    }

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

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

    }

}

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

using namespace std;

#define int long long

typedef pair<int,int> P;

int INF = 1e16+7;

int mod = 1e9+7;

int dx[4] = {1, 0, -1, 0};

int dy[4] = {0, 1, 0, -1};

signed main(){

    int N,M;

    cin >> N >> M;

    vector<vector<P>>ID(N);

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

        int P,Y;

        cin >> P >> Y;

        P--;

        ID[P].push_back({Y,i});

    }

    vector<P>ans(M);

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

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

        int cnt = 1;

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

            ans[ID[i][j].second] = {i+1,cnt};

            cnt++;

        }

    }

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

        int X = ans[i].first;

        int Y = ans[i].second;

        printf("%06lld%06lld\n",X,Y);

    }

}


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

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

#define P pair<int,int>

#define int long long

#define LONG LLONG_MAX/3;

#define INT INT_MAX/3;

#define mod 1000000007

typedef long long ll;

using namespace std;



pair<P,int> p[100000];

string s[100000];



int keta(int a){

	int b=0;

	while(a){

		a/=10;

		b++;

	}

	return b;

}

int mypow(int a,int b){

	if(b==0)return 1;

	if(b%2)return mypow(a,b-1)*a%mod;

	return mypow(a,b/2)*mypow(a,b/2)%mod;

}

int kaijo(int n){

	int ans=1;

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

		ans*=i;

		ans%=mod;

	}

	return ans;

}

int gcd(int a,int b){

	if(b==0) return a;

	return gcd(b,a%b);

}

int lcm(int a,int b){

	return a/gcd(a,b)*b;

}



signed main(){

	int n,m,x=1;

	cin>>n>>m;

	f(i,m){

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

		p[i].second=i;

	}

	sort(p,p+m);

	f(i,m){

		if(i){

			if(p[i].first.first==p[i-1].first.first) x++;

			else x=1;

		}

		f(j,6-keta(p[i].first.first)) s[p[i].second]+="0";

		s[p[i].second]+=to_string(p[i].first.first);

		f(j,6-keta(x)) s[p[i].second]+="0";

		s[p[i].second]+=to_string(x);

	}

	f(i,m) cout<<s[i]<<endl;

	return 0;

}


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

#define int long long

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

#define F first

#define S second

#define mod 1000000007

#define P pair<int,int>

using namespace std;

pair<P,int> p[100000];

P x[100000];

signed main(){

	int a,b;

	cin>>a>>b;

	f(i,b){

		cin>>p[i].F.F>>p[i].F.S;

		p[i].S=i;

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

	}

	sort(p,p+b);

	int z=1;

	f(i,b){

		if(i&&p[i].F.F!=p[i-1].F.F){

			z=1;

		}

		x[p[i].S].S=z;

		z++;

	}

	f(i,b){

		int c=6,d=x[i].F;

		while(d){

			d/=10;

			c--;

		}

		f(i,c) cout<<0;

		cout<<x[i].F;

		c=6;

		d=x[i].S;

		while(d){

			d/=10;

			c--;

		}

		f(i,c) cout<<0;

		cout<<x[i].S<<endl;

	}

	return 0;

}


// Fastest known solution for this problem: