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

#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int>P;

int n,m;

vector<P> v,v1;

int s[100001];

string f(int x){

    if(x<10)return "00000";

    else if(x<100)return "0000";

    else if(x<1000)return "000";

    else if(x<10000)return "00";

    else if(x<100000)return "0";

    else return "";

}

int main(void){

    cin>>n>>m;

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

        int a,b;

        cin>>a>>b;

        v.push_back(P(a,b));

        v1.push_back(P(a,b));

        s[a]++;

    }

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

        s[i+1]+=s[i];

        //cout<<s[i]<<endl;

    }

    

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

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

        cout<<f(v1[i].first)<<v1[i].first;

        int mid=upper_bound(v.begin(),v.end(),v1[i])-v.begin();

        mid-=s[v1[i].first-1];

        cout<<f(mid)<<mid<<endl;

    }

}


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

#include<bits/stdc++.h>

#define F first

#define S second

using namespace std;

typedef long long ll;

typedef pair<pair<ll,ll>,ll>P;

ll n,m,a,b;

vector<P>v;

ll ans[100000][2];

int main(void){

    cin>>n>>m;

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

        cin>>a>>b;

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

    }

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

    //cout<<setfill('0')<<setw(4)<<12<<endl;

    ll l=0,ch=0;

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

        if(v[i].F.F!=ch){

            ch=v[i].F.F;

            l=i;

        }

        ans[v[i].S][0]=v[i].F.F;

        ans[v[i].S][1]=i-l+1;

    }

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

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

        cout<<setfill('0')<<setw(6)<<ans[i][1]<<endl;

    }

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

using namespace std;



typedef long long ll;



int N, M;

int P[100000], Y[100000];

vector<int> yd[100001];



int main() {

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

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

        scanf("%d %d ", &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 lb  = lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]);

        int rank = lb - yd[P[i]].begin() + 1;

        printf("%06d%06d\n", P[i], rank);

    }

}


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

using namespace std;

typedef long long ll;

//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



/* attention

    long longのシフト演算には気をつけよう

    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも

*/



int main(){

    int N, M; cin >> N >> M;

    vector<int> p(M), y(M);

    vector<int> order[N+1];



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

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

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

    }



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



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

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

        int rank = itr - order[p[i]].begin() + 1;

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

    }

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

using namespace std;





int main(){

    int P[100000], Y[100000];

    vector<int> V[100001];

    int N,M;

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



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

        scanf("%d %d", &P[i], &Y[i]);

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

    }



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

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

    }



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

        auto it=lower_bound(V[P[i]].begin(), V[P[i]].end(), Y[i]);

        int rank=it-V[P[i]].begin()+1;

        printf("%06d%06d\n", P[i], rank);

    }



    return 0;

}

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

using namespace std;

typedef long long ll;

//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



/* attention

    long longのシフト演算には気をつけよう

    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも

*/



int main(){

    int N, M; cin >> N >> M;

    vector<int> p(M), y(M);

    vector<int> order[N+1];



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

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

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

    }



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



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

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

        int rank = itr - order[p[i]].begin() + 1;

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

    }

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

using namespace std;

typedef long long ll;



int main(void){

    int N,M; cin >> N >> M;

    vector<int> P(M), Y(M);

    vector<int> V[100001];



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

        cin >> 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=0; i<M; i++){

        auto it1=lower_bound(V[P[i]].begin(), V[P[i]].end(), Y[i]);

        int rank=it1-V[P[i]].begin()+1;

        printf("%06d%06d\n", P[i], rank);

    }



}

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

using namespace std;

typedef long long ll;

//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



/* attention

    long longのシフト演算には気をつけよう

    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも

*/



int main(){

    int N, M; cin >> N >> M;

    vector<int> p(M), y(M);

    vector<int> order[N+1];



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

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

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

    }



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



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

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

        int rank = itr - order[p[i]].begin() + 1;

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

    }

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

using namespace std;



typedef long long ll;



int N, M;

int P[100000], Y[100000];

vector<int> yd[100001];



int main() {

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

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

        scanf("%d %d ", &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 lb  = lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]);

        int rank = lb - yd[P[i]].begin() + 1;

        printf("%06d%06d\n", P[i], rank);

    }

}


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

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

 

/* attention

    long longのシフト演算には気をつけよう

    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも

    sizeは(int)とキャストしよう

    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？

*/

 

const ll mod = 1e9+7;



void chmod(ll &M){

    if(M >= mod) M %= mod;

    else if(M < 0){

        M += (abs(M)/mod + 1)*mod;

        M %= mod;

    }

}



ll modpow(ll x, ll n){

    if(n == 0) return 1;



    ll res = modpow(x, n/2);

    if(n%2 == 0) return res*res%mod;

    else return res*res%mod*x%mod;

}



typedef tuple<int, int, int> T;



int main(){

    cin.tie(0);

	ios::sync_with_stdio(false);



    int n, m; cin >> n >> m;

    vector<T> pyid(m);

    vector<int> year[n+1];

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

        int p, y; cin >> p >> y;

        pyid[i] = make_tuple(p, y, i+1);

        year[p].push_back(y);

    }



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

    

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

        int p, y, id;

        tie(p, y, id) = pyid[i];



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

        int rank = itr-year[p].begin()+1;

        printf("%06d%06d\n", p, rank);

    }

    

    return 0;

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

using namespace std;





int main(){

    int P[100000], Y[100000];

    vector<int> V[100001];

    int N,M;

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



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

        scanf("%d %d", &P[i], &Y[i]);

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

    }



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

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

    }



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

        auto it=lower_bound(V[P[i]].begin(), V[P[i]].end(), Y[i]);

        int rank=it-V[P[i]].begin()+1;

        printf("%06d%06d\n", P[i], rank);

    }



    return 0;

}

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

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

 

/* attention

    long longのシフト演算には気をつけよう

    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも

    sizeは(int)とキャストしよう

    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？

*/

 

const ll mod = 1e9+7;



void chmod(ll &M){

    if(M >= mod) M %= mod;

    else if(M < 0){

        M += (abs(M)/mod + 1)*mod;

        M %= mod;

    }

}



ll modpow(ll x, ll n){

    if(n == 0) return 1;



    ll res = modpow(x, n/2);

    if(n%2 == 0) return res*res%mod;

    else return res*res%mod*x%mod;

}



typedef tuple<int, int, int> T;



int main(){

    cin.tie(0);

	ios::sync_with_stdio(false);



    int n, m; cin >> n >> m;

    vector<T> pyid(m);

    vector<int> year[n+1];

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

        int p, y; cin >> p >> y;

        pyid[i] = make_tuple(p, y, i+1);

        year[p].push_back(y);

    }



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

    

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

        int p, y, id;

        tie(p, y, id) = pyid[i];



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

        int rank = itr-year[p].begin()+1;

        printf("%06d%06d\n", p, rank);

    }

    

    return 0;

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

using namespace std;

typedef long long ll;



int main(void){

    int N,M; cin >> N >> M;

    vector<int> P(M), Y(M);

    vector<int> V[100001];



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

        cin >> 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=0; i<M; i++){

        auto it1=lower_bound(V[P[i]].begin(), V[P[i]].end(), Y[i]);

        int rank=it1-V[P[i]].begin()+1;

        printf("%06d%06d\n", P[i], rank);

    }



}

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

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

 

/* attention

    long longのシフト演算には気をつけよう

    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも

    sizeは(int)とキャストしよう

    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？

*/

 

const ll mod = 1e9+7;



void chmod(ll &M){

    if(M >= mod) M %= mod;

    else if(M < 0){

        M += (abs(M)/mod + 1)*mod;

        M %= mod;

    }

}



ll modpow(ll x, ll n){

    if(n == 0) return 1;



    ll res = modpow(x, n/2);

    if(n%2 == 0) return res*res%mod;

    else return res*res%mod*x%mod;

}



typedef tuple<int, int, int> T;



int main(){

    cin.tie(0);

	ios::sync_with_stdio(false);



    int n, m; cin >> n >> m;

    vector<T> pyid(m);

    vector<int> year[n+1];

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

        int p, y; cin >> p >> y;

        pyid[i] = make_tuple(p, y, i+1);

        year[p].push_back(y);

    }



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

    

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

        int p, y, id;

        tie(p, y, id) = pyid[i];



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

        int rank = itr-year[p].begin()+1;

        printf("%06d%06d\n", p, rank);

    }

    

    return 0;

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

using namespace std;



int main() {

  int N,M;

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

  int P[M],Y[M];

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

    scanf("%d %d", &P[i],&Y[i]);

  }



  vector<int> yd[100001];

  for (int i = 0; i < M; ++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) printf("%06d%06d\n", P[i],int(lower_bound(yd[P[i]].begin() ,yd[P[i]].end(), Y[i]) - yd[P[i]].begin())+1);

  



}




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

using namespace std;



int main() {

  int N,M;

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

  int P[M],Y[M];

  vector<pair<pair<int,int>,int>> cities;

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

    scanf("%d %d", &P[i],&Y[i]);

    cities.push_back(make_pair(make_pair(Y[i], P[i]), i));

  }



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



  vector<int>num(M), cnt(N+1);



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

    ++cnt[cities[i].first.second];

    num[cities[i].second] = cnt[cities[i].first.second];

  }



  for (int i = 0;i < M;++i) printf("%06d%06d\n", P[i],num[i]);

  





  



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

#include <vector>

#include <algorithm>

#include <cstdio>

using namespace std;



int main()

{

  int n, m;

  cin >> n >> m;



  vector<pair<int, int> > v;

  vector<int> u[100001];

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

    int p, y;

    cin >> p >> y;

    v.push_back(make_pair(p, y));

    u[p].push_back(y);

  }



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

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

  }



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

    int p = v[i].first;

    printf("%06d%06d\n", p, (int)(lower_bound(u[p].begin(), u[p].end(), v[i].second) - u[p].begin() + 1));

  }



  return 0;

}


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

using namespace std;



#ifdef LOCAL

    #define eprintf(...) fprintf(stderr, __VA_ARGS__)

#else

        #define eprintf(...) 42

#endif



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

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

#define all(x) (x).begin(),(x).end()

#define foreach(u,v) for(auto (u) : (v))

#define pb push_back

#define mp make_pair

#define mt make_tuple



typedef long long ll;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef pair<ll, ll> pll;

typedef vector<ll> vl;



const int inf = 1e9;

const ll linf = 1LL<<60;

const ll mod = 1e9 + 7;

const double eps = 1e-9;



/*

*/



int main()

{

  int n, m;

  cin >> n >> m;



  vector<pii> v[n+1];

  rep(i, m){

    int p, y;

    cin >> p >> y;

    v[p].pb({y, i}); 

  }



  rep(i, n+1) sort(all(v[i]));



  vector<ll> ans(m);

  rep(i, n+1){

    rep(j, v[i].size()){

      ans[v[i][j].second] = (ll)i*1000000+j+1;

    }

  }



  for(ll i : ans){

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

  }



  return 0;

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

using namespace std;

typedef pair<int,int> P;

int main(void){

  int n,m,i,j,pi,y;

  P ans[100010];

  vector<P> p[100010];

  cin >> n >> m;

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

    cin >> pi >> y;

    p[pi-1].push_back(P(y,i));

  }

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

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

    for (j=0;j<p[i].size();j++) ans[p[i][j].second]=P(i+1,j+1);

  }

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

    int d=10,k=5;

    while (ans[i].first >= d){

      d*=10;

      k--;

    }

    for (j=0;j<k;j++) cout << 0;

    cout << ans[i].first;

    d=10;

    k=5;

    while (ans[i].second >= d){

      d*=10;

      k--;

    }

    for (j=0;j<k;j++) cout << 0;

    cout << ans[i].second << endl;

  }

  return 0;

}

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

#include <algorithm>

#include <vector>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;





int dn(int x) {

	if (x >= 100000) return 0;

	else if (x >= 10000) return 1;

	else if (x >= 1000) return 2;

	else if (x >= 100) return 3;

	else if (x >= 10) return 4;

	else return 5;

}



int main(void) {

	int n, m, i, j, p[100003], y, b[100003], k;

	vector<P> v[100003];



	cin >> n >> m;

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

		cin >> p[i] >> y;

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

	}



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

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

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

			b[v[i][j].second] = j + 1;

		}

	}



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

		k = dn(p[i]);

		for (j = 0; j < k; j++) cout << 0;

		cout << p[i];

		k = dn(b[i]);

		for (j = 0; j < k; j++) cout << 0;

		cout << b[i] << 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: 1.2505540477333879x):
#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
// 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: 1.2491399024398877x):
#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;

}
// 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.8503076451073313x):
#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;

}