stablegradients/pie-gem5-pairs huggingface dataset:
// 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.8493998037738877x):
#include <iostream>

#include<cstdio>

#include<algorithm>

#define ll 100005

using namespace std;

struct st

{

    int x,y,w;

} a[ll],b[ll];

bool cmp(st p,st q)

{

    if(p.x==q.x)

        return p.y<q.y;

    return p.x<q.x;

}

int main()

{

    int n,m;

    cin>>n>>m;

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

    {

        a[i].w=i;

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

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

    }

    sort(a,a+m,cmp);

    int t=a[0].x,k=1;

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

    {

        if(a[i].x!=t)

        {

            k=1;

            t=a[i].x;

        }

        b[a[i].w].y=k++;

    }

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

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

    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.413873924038479x):
#include <iostream>

#include<cstdio>

#include<algorithm>

#define ll 100005

using namespace std;

struct st

{

    int x,y,w;

} a[ll],b[ll];

bool cmp(st p,st q)

{

    if(p.x==q.x)

        return p.y<q.y;

    return p.x<q.x;

}

int main()

{

    int n,m;

    cin>>n>>m;

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

    {

        a[i].w=i;

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

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

    }

    sort(a,a+m,cmp);

    int t=a[0].x,k=1;

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

    {

        if(a[i].x!=t)

        {

            k=1;

            t=a[i].x;

        }

        b[a[i].w].y=k++;

    }

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

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

    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.529534714663925x):
#include <iostream>

#include<cstdio>

#include<algorithm>

#define ll 100005

using namespace std;

struct st

{

    int x,y,w;

} a[ll],b[ll];

bool cmp(st p,st q)

{

    if(p.x==q.x)

        return p.y<q.y;

    return p.x<q.x;

}

int main()

{

    int n,m;

    cin>>n>>m;

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

    {

        a[i].w=i;

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

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

    }

    sort(a,a+m,cmp);

    int t=a[0].x,k=1;

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

    {

        if(a[i].x!=t)

        {

            k=1;

            t=a[i].x;

        }

        b[a[i].w].y=k++;

    }

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

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

    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.5335304839890727x):
#include <iostream>

#include<cstdio>

#include<algorithm>

#define ll 100005

using namespace std;

struct st

{

    int x,y,w;

} a[ll],b[ll];

bool cmp(st p,st q)

{

    if(p.x==q.x)

        return p.y<q.y;

    return p.x<q.x;

}

int main()

{

    int n,m;

    cin>>n>>m;

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

    {

        a[i].w=i;

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

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

    }

    sort(a,a+m,cmp);

    int t=a[0].x,k=1;

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

    {

        if(a[i].x!=t)

        {

            k=1;

            t=a[i].x;

        }

        b[a[i].w].y=k++;

    }

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

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

    return 0;

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

}

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

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

}

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

}



void pakuri_sort(int N, ll A[]) {

	const int b = 8;

	int tmp[100001];

	rep(k, 8) {

		int kazu[1 << b] = {}, kazu2[1 << b] = {};

		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];

		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];

		k++;

		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];

		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];

	}

}



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;

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

}

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

    }

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

  }

}

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

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

}

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

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

}

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

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

        int p, y;

        cin >> p >> y;

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

    }

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



    vector<P> res(M);

    int i = 0, prev = 0, cnt = 0;

    while (i < M) {

        if (prev != city[i].first.first) {

            prev = city[i].first.first;

            cnt = 0;

        } else {

            cnt++;

        }



        res[city[i].second] = P(city[i].first.first, cnt + 1);

        i++;

    }



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

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

        cout << endl;

    }

    return 0;

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

}

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

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

        int p, y;

        cin >> p >> y;

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

    }

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



    vector<P> res(M);

    int pre = 0, cnt = 1;

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

        if (city[i].first.first != pre) {

            pre = city[i].first.first;

            cnt = 1;

        } else {

            cnt++;

        }

        res[city[i].second] = P(city[i].first.first, cnt);

    }



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

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

        cout << endl;

    }

    return 0;

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

}

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

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

}

// Faster C++ solution for the same problem (measured speedup: 3.597275107323409x):
#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 pre = 0, cnt = 0;

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

        int p = C[i].first.first;

        if (p == pre) {

            cnt++;

        } else {

            cnt = 1;

        }

        pre = p;

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

    }



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

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

    }

    return 0;

}