stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> ii;

const int mod = 1e9+7;

const ll INF = 1e18;

const int inf = 1e9;



void solve()

{

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

  vector<int> p(m, 0);

  vector<int> y(m, 0);

  vector<vector<int>> yd(100001);

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

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

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

  }

}



int main()

{

  solve();

  return 0;

}


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

using namespace std;

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

typedef long long ll;



#ifdef _DEBUG

inline void dump() { cerr << endl; }

template<typename Head> void dump(Head&& head) { cerr << head; dump(); }

template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }

#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)

#else

#define dump(...)

#define debug(...)

#endif



template<typename T>

struct edge {

  int src, to;

  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {

    to = x;

    return *this;

  }

  operator int() const { return to; }

};

template<typename T>

using Edges = vector<edge<T>>;

template<typename T>

using WeightedGraph = vector<Edges<T>>;

using UnWeightedGraph = vector<vector<int>>;

template<typename T>

using Matrix = vector<vector<T>>;



/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;



struct S {

  int p, y, i;

};



bool comp(pair<int,int> a, pair<int,int> b)

{

  if (a.second != b.second) {

    return a.second < b.second;

  }

  return a.first < b.first;

}



bool c1(S a, S b)

{

  if (a.p != b.p) {

    return a.p < b.p;

  }

  return a.y < b.y;

}



bool c2(S a, S b)

{

  return a.i < b.i;

}



int main()

{

  ll n, m; cin>>n>>m;

  vector<S> a(m);

  rep(i, m) {

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

    a[i] = S{p, y, i};

  }

  sort(a.begin(),a.end(), c1);

  a[0].y = 1;

  rep(i, m) {

    if (a[i].p == a[i-1].p) a[i].y = a[i-1].y+1;

    else a[i].y = 1;

  }

  sort(a.begin(),a.end(), c2);

  rep(i, m) {

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

  }



  return 0;

}


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

#include <algorithm>

#include <cstring>

#include <cstdio>

#include <vector>

#include <queue>

#include <stack>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <cassert>

#include <ctime>

#include <cstdlib>

#include <map>

#include <set>

using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")

#define lowbit(x) (x&(-x))

#define max(x,y) (x>=y?x:y)

#define min(x,y) (x<=y?x:y)

//#define MAX 100000000000000000

#define MOD 1000000007

#define pi acos(-1.0)

#define ei exp(1)

#define PI 3.1415926535897932384626433832

#define ios() ios::sync_with_stdio(true)

#define INF (1<<31)-1;

#define mem(a) (memset(a,0,sizeof(a)))

struct P{

    int x,y;

}H[200000];

vector<int>G[200000];

int POS(int k,int value){

    int mid;

    int left = 0;

    int len = G[k].size();

    int right = len - 1;

    //cout<<" "<<k<<"A"<<value<<endl;

    while(left <= right){

 

        // 确保中点靠近区间的起点

        mid = left + (right-left)/2;

        //cout<<mid<<endl;

        //cout<<"mid= "<<mid<<" "<<left<<" "<<right<<endl;

        // 如果找到则返回

        if(G[k][mid] == value) return mid;

        // 将中点赋给终点

        else if(G[k][mid] > value) right = mid;

        // 将中点加一赋给起点

        else left = mid + 1;

    }

    return -1;

}

set<int>::iterator it;

int main()

{

    set<int>s;

    int N,M;

    int x,y;

    cin>>N>>M;

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

        cin>>x>>y;

        H[i].x = x;

        H[i].y = y;

        G[x].push_back(y);

        s.insert(x);

    }

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

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

    }

 

 

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

        cout<<setw(6)<<setfill('0')<<H[i].x;

        cout<<setw(6)<<setfill('0')<<POS(H[i].x,H[i].y)+1<<endl;

    }

    return 0;

}

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

#include<iostream>

#include<fstream>

#include<algorithm>

#include<functional>

#include<cstring>

#include<string>

#include<cstdlib>

#include<iomanip>

#include<numeric>

#include<cctype>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<list>

#include<set>

#include<map>

using namespace std;

#define N 100000+5

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

#define sd(n) scanf("%d",&n)

#define sll(n) scanf("%I64d",&n)

#define pd(n) scanf("%d\n",n)

#define pll(n) scanf("%I64d\n",n)

#define MAX 26

typedef long long ll;

const ll mod=1e9+7;

int n,m;

int a[N];

int b[N];

vector<int>p[N];

int main()

{

	 //string s;

	 //cin>>s;

	 //ll ans=0;

	 //ll sum=0;

	scanf("%d",&n);

	scanf("%d",&m);

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

	{

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

		p[a[i]].push_back(b[i]);

	}

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

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

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

	{



		int pos=lower_bound(p[a[i]].begin(),p[a[i]].end(),b[i])-p[a[i]].begin()+1;

		printf("%06d%06d\n",a[i],pos);

	}

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

	//	printf("%I64d",a[i]);

		

	//printf("%I64d\n",ans);

    return 0;

}


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

#include <iomanip>

#include <iostream>

#include <set>

#include <string>

#include <vector>

#define SORT(a) sort((a).begin(), (a).end())

#define RSORT(a) sort((a).rbegin(), (a).rend())

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

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

using namespace std;



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);



    int n, m;

    cin >> n >> m;



    int p[100000], y[100000];

    vector<int> yd[100001];

    REP(i, m) {

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

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

    }



    REP(i, n) { SORT(yd[i + 1]); }

    REP(i, m) {

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

        cout << setfill('0') << setw(6)

             << lower_bound(ALL(yd[p[i]]), y[i]) - yd[p[i]].begin() + 1 << endl;

    }



    return 0;

}

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

#include <iomanip>

#include <iostream>

#include <queue>

#include <set>

#include <string>

#include <vector>

#define SORT(a) sort(a.begin(), a.end())

#define RSORT(a) sort(a.rbegin(), a.rend())

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

#define RREP(i, n) for (int i = n; 0 <= i; i--)

#define FOR(i, start, end) for (int i = start; i < end; i++)

#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)

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

#define MOD(a) a %= 1000000007

typedef long long ll;

const int INF32 = 2147483647;

const ll INF64  = 9223372036854775807;

using namespace std;



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);



    int N, M;

    cin >> N >> M;

    vector<pair<int, pair<int, int>>> A(M);

    REP(i, M) {

        int a, b;

        cin >> a >> b;

        A[i].first         = a;

        A[i].second.first  = b;

        A[i].second.second = i;

    }

    vector<pair<int, pair<int, int>>> B = A;

    SORT(B);

    vector<int> index(M);

    vector<int> id(N + 1, 1);

    REP(i, M) {

        index[B[i].second.second] = id[B[i].first];

        id[B[i].first]++;

    }



    REP(i, M) {

        cout << setfill('0') << setw(6) << A[i].first;

        cout << setfill('0') << setw(6) << index[i] << '\n';

    }



    return 0;

}

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

using namespace std;



typedef long long int ll;

typedef pair<ll, ll> pll;



#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))

#define REP(i, n) FOR(i, n, 0)

#define OF64 std::setprecision(10)



const ll MOD = 1000000007;

const ll INF = (ll)1e15;



struct Data

{

    int y;

    int p;

    int i;

};

Data D[100005];

string A[100005];



string create(int p, int n)

{

    string a = "", b = "";

    REP(i, 6)

    {

        a = (char)('0' + p % 10)+a;

        b = (char)('0' + n % 10)+b;

        p /= 10;

        n /= 10;

    }

    return a + b;

}



int main()

{

    int N, M;

    cin >> N >> M;

    REP(i, M)

    {

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

        D[i].i = i;

    }

    sort(D, D + M, [](Data a, Data b) { return a.p == b.p ? a.y < b.y : a.p < b.p; });

    int pi = 0;

    REP(i, M)

    {

        if (D[pi].p != D[i].p)

        {

            pi = i;

        }

        A[D[i].i] = create(D[i].p, i - pi + 1);

    }

    REP(i, M)

    {

        cout << A[i]<<endl;

    }

    return 0;

}

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

using namespace std;



typedef long long int ll;

typedef pair<ll, ll> pll;



#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))

#define REP(i, n) FOR(i, n, 0)

#define OF64 std::setprecision(10)



const ll MOD = 1000000007;

const ll INF = (ll)1e15;



struct Data

{

    ll P;

    ll Y;

    ll i;

};

Data D[100005];

pll A[100005];



int main()

{

    ll N, M;

    cin >> N >> M;

    REP(i, M)

    {

        cin >> D[i].P >> D[i].Y;

        D[i].i = i;

    }

    sort(D, D + M, [](Data a, Data b) { return a.P == b.P ? a.Y < b.Y : a.P < b.P; });

    int num = 1;

    REP(i, M)

    {

        if (i == 0 || D[i].P != D[i - 1].P)

            num = 1;

        A[D[i].i].first = D[i].P;

        A[D[i].i].second = num++;

    }



    REP(i, M)

    {

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

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

        cout << endl;

    }

    return 0;

}

// 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;

    

    map<int,int> Year;

    map<int,int> origin;

    vector<int> P(M);

    vector<int> Y(M);

    int i;

    

    

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

        cin>>P[i]>>Y[i];

        Year[Y[i]]=P[i];

        origin[Y[i]]=i;

    }

    

    

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

    

    for(i=0;i<M;i++)P[i]=Year[Y[i]];

    

    int up[M];

    int down[M];

    int sum[100001]={0};

    

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

        up[origin[Y[i]]]=P[i];

        sum[P[i]]++;

        down[origin[Y[i]]]=sum[P[i]];

        

    }

    

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

    

}

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

using namespace std;

typedef pair<int,int> P;

int main(){

    int N, M;

    cin >> N >> M;

    vector<int> v[N];

    vector<P> sub(M);

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

        int p, y;

        cin >> p >> y;

        p--;

        v[p].push_back(y);

        sub[i] = P(p, y);

    }

    

    map<P,int> ma;

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

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

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

            ma[P(i, v[i][j])] = j + 1;

        }

    }

    

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

        int p = sub[i].first + 1;

        int num = ma[sub[i]];

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

    }

}

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

#include <string>

#include <vector>

#include <map>

#include <cmath>

#include <algorithm>

#include <functional>

using namespace std;



//素数判定

inline bool IsPrime(int p) {

	if (p == 1) return false;

	for (int i = 2; i <= sqrt(p); i++) {

		if (p%i == 0) return false;

	}

	return true;

}



//10進数の自然数の桁数を返す

inline int GetDigit(int num) {

	return (int)log10(num) + 1;

}



//各位の和を返す

int GetDigitsSum(int num) {

	int N = 0;

	while (num > 0) {

		N += num % 10;

		num /= 10;

	}

	return N;

}







//異なるn個からr個の整数を取り出す組合せの数を求める

int combination(int n, int r) {

	if (r == 0 || n == r) {

		return 1;

	}

	else if (r == 1) {

		return n;

	}

	else {

		return combination(n - 1, r - 1) + combination(n - 1, r);

	}



}



struct MyStruct

{

	int x;

	int no;

	int P;

	int Y;

};



struct city

{

	vector<MyStruct> M;



};



struct ans

{

	int P;

	int x;

	int no;

};



bool cmp(const ans &a, const ans &b)

{

	return a.no < b.no;

}



bool cmpY(const MyStruct &a, const MyStruct &b) {

	return a.Y < b.Y;

}



int main() {

	int N, M;



	vector<city> c(100001);

	vector<ans> AAA;



	cin >> N >> M;

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

	{

		MyStruct tmp;

		cin >> tmp.P >> tmp.Y;

		tmp.no = i;

		c[tmp.P].M.push_back(tmp);

	}



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

	{

		sort(c[i].M.begin(), c[i].M.end(),cmpY);

		int n = (int)c[i].M.size();

		int dtx = 1;

		for (int j = 0; j < n; j++)

		{

			c[i].M[j].x = dtx++;

		}



		for (int j = 0; j < n; j++)

		{

			ans A;

			A.no = c[i].M[j].no;

			A.P = c[i].M[j].P;

			A.x = c[i].M[j].x;

			AAA.push_back(A);

		}

	}



	sort(AAA.begin(), AAA.end(), cmp);

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

	{

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

	}



	return 0;

}


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

#include <string>

#include <vector>

#include <map>

#include <cmath>

#include <algorithm>

#include <functional>

#include <stack>

#include <numeric>

typedef long long ll;

using namespace std;

const int MOD = (int)1e9 + 7;

const ll INF = (ll)1e18 + 7;

//#define int long long



struct MyStr{

	int Y;

	int P;

	int No;

	int X;

};



bool cmp_no(const MyStr &a, const MyStr &b) {

	return a.No < b.No;

}



bool cmp(const MyStr &a, const MyStr &b) {

	if (a.P == b.P) {

		return a.Y < b.Y;

	}

	else {

		return a.P < b.P;

	}

}



signed main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, M;

	cin >> N >> M;

	vector<MyStr> vec(M);



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

	{

		cin >> vec[i].P >> vec[i].Y;

		vec[i].No = i;

	}



	sort(vec.begin(), vec.end(), cmp);



	int t = 1;

	vec[0].X = 1;

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

	{

		if (vec[i - 1].P != vec[i].P) {

			vec[i].X = 1;

			t = 1;

		}

		else {

			vec[i].X = ++t;

		}

	}



	sort(vec.begin(), vec.end(), cmp_no);



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

	{

		printf("%06d%06d\n", vec[i].P,vec[i].X);

	}



	return 0;

}


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

using namespace std;



vector<vector<int>> group((100001), vector<int>(0, 0));



int getNumber(int n, int left, int right, int target) {

	int mid = (left + right) / 2;

	while(true) {

		mid = (left + right) / 2;

		if (group.at(n).at(mid) == target) {

			return mid;

		}

		else if (group.at(n).at(mid) < target) {

			left = mid + 1;

		}

		else {

			right = mid - 1;

		}

	}

} 



int main(){

    int n,m;

	cin >> n >> m;

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

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

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

		group.at(p.at(i)).push_back(y.at(i));

	}

    

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

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

	}

	

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

		cout << setfill('0') << setw(6) << right << p.at(i) << setfill('0') << setw(6) << right << getNumber(p.at(i), 0, group.at(p.at(i)).size() - 1, y.at(i)) + 1 << endl;

	}

}


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

#include <cmath>

#include <complex>

#include <iostream>

#include <map>

#include <queue>

#include <set>

#include <vector>

#include <functional>

#include <cstring>



using namespace std;



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

#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)



using ll = long long;

using P = pair<int, int>;



const long long MOD = 1e9+7;



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

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



template<class T>

istream& operator >>(istream &is, vector<T> &v) {

    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);

    return is;

}



int main() {

    int n, m;

    cin >> n >> m;

    using tpl = tuple<int, int, int>;

    vector<tpl> x(m + 1);

    x[0] = tpl(-1, -1, -1);

    vector<P> number(m);

    rep(i, m) {

        int p, y;

        cin >> p >> y;

        x.at(i + 1) = tpl(p, y, i);

    }

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

    

    int num = 1;

    rep(i, m) {

        int p, y, nm;

        tie(p, y, nm) = x.at(i + 1);

        if (get<0>(x.at(i)) != p) num = 1;

        else num++;

        number.at(nm) = P(p, num);

    }

    

    rep(i, m) {

        int p = number.at(i).first, nm = number.at(i).second;

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

    }

}

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

#include <vector>

#include <algorithm>

#include <iostream>



using namespace std;

typedef long long ll;



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

				printf("%012lld\n", ll(P[i])*1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);

		}

		

		return 0;

}


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

#include <cstdio>

#include <vector>

#include <algorithm>



using namespace std;



typedef long long ll;



int main() {

		int N, M;

		cin >> N >> M;

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

		vector<int> d[N + 1];

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

				cin >> P[i] >> Y[i];

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

		}



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

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

		}



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

				printf( "%012lld\n", ll(P[i]) * 1000000 + (int)(lower_bound(d[P[i]].begin(), d[P[i]].end(), Y[i]) - d[P[i]].begin()) + 1 );

		}

		

		return 0;

}


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

#include<vector>

#include<algorithm>

#include<map>

#include<cstring>

#include<math.h>

#include<bitset>

#include<queue>

#include<set>

#include<iomanip>

#include<math.h>

// #include<bits/stdc++.h>

using namespace std;

#define ll long long

constexpr long long int INFLL = 1001001001001001LL;

constexpr int INFI = 1000000007;



int main(){

  int N,M;

  cin >> N >> M;

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

  vector<int> yd[100001];

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

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

    cout << setfill('0') << right << setw(6) << lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-(yd[P[i]].begin())+1 << endl;

  }

  return 0;

}


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

#include<vector>

#include<algorithm>

#include<map>

#include<cstring>

#include<math.h>

#include<bitset>

#include<queue>

#include<set>

#include<iomanip>

#include<math.h>

#include<assert.h>

#include<string>

#include<cstdlib>

#include<cctype>

#include<unordered_map>

#include<sstream>

#include<numeric>

#include<stack>

// #include<bits/stdc++.h>

using namespace std;

using ll = long long;

using P = pair<int,int>;

constexpr ll INF = 1LL<<60;

const double INFD = 1e100;

const ll mod = 1000000007;

const double PI = 3.1415926535897932384626433832795028841971;

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

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

template<class T> inline bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

};

template<class T> inline bool chmax(T& a, T b) {

    if (a < b) {

        a = b;

        return true;

    }

    return false;

};



// intやllをstringに変換

template<typename T> inline string toString(const T &a){

  ostringstream oss;

  oss << a;

  return oss.str();

};

// ----------------------------------------------------------------------------



int main(){

  int N,M;

  cin >> N >> M;

  vector<vector<int>> G(N);

  vector<P> id(M);

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

    int P,Y;

    cin >> P >> Y;

    P--;

    G[P].push_back(Y);

    id[i] = make_pair(P,Y);

  }

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

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

  }

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

    id[i].second = lower_bound(G[id[i].first].begin(),G[id[i].first].end(),id[i].second) - G[id[i].first].begin();

  }

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

    cout << setfill('0') << right << setw(6) << id[i].first+1;

    cout << setfill('0') << right << setw(6) << id[i].second+1 << endl;

  }

  return 0;

}


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

#include<cstdio>

#include<algorithm>

#define f first

#define s second

using namespace std;



typedef pair<pair<long,long>,pair<long,long> > pp;



bool ppc(pp& f,pp& s){return f.s.s<s.s.s;}



int main()

{

	int n,m,p,y;

	cin>>n>>m;

	pp a[100010];

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

	{

		cin>>p>>y;

		a[i].f.f=p;

		a[i].f.s=y;

		a[i].s.f=0;

		a[i].s.s=i;

	}

	sort(a+1,a+m+1);

	p=a[1].f.f;

	y=1;

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

	{

		if(p!=a[i].f.f)p=a[i].f.f,y=1;

		a[i].s.f=y;

		y++;

	}

	sort(a+1,a+m+1,ppc);

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

	{

		printf("%012ld\n",a[i].f.f*1000000l+a[i].s.f);

	}

	return 0;

}

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

#include<cstdio>

#include<algorithm>

#define f first

#define s second

using namespace std;



typedef pair<pair<int,int>,pair<int,int> > P;



bool PC(P& f,P& s){return f.s.s<s.s.s;}



int main()

{

	int n,m,p,y;

	P a[100010];

	cin>>n>>m;

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

	{

		cin>>p>>y;

		a[i].f.f=p;

		a[i].f.s=y;

		a[i].s.f=0;

		a[i].s.s=i;

	}

	sort(a,a+m);

	p=a[0].f.f;

	y=0;

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

	{

		if(p!=a[i].f.f)p=a[i].f.f,y=0;

		a[i].s.f=++y;

	}

	sort(a,a+m,PC);

	for(int i=0;i<m;i++)printf("%012ld\n",(long)(a[i].f.f*1e6+a[i].s.f));

	return 0;

}

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

#include<iomanip>

#include<vector>

#include<algorithm>

using namespace std;



int main(){

  int N,M;

  cin >> N >> M;

  int P[100000];

  int Y[100000];

  vector<int>Y_num[100001];



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

	cin >> P[i] >> Y[i];

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

  }



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

	sort(Y_num[i+1].begin(),Y_num[i+1].end());

  }

  

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

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

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



	cout << endl;

  }

  





  return 0;

}


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

#include<iomanip>

#include<vector>

#include<algorithm>

using namespace std;



int main(){

  int N,M;

  cin >> N >> M;

  int P[M+1];

  int Y[M+1];

  vector<int>Y_num[N+1];

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

	cin >> P[i] >> Y[i];

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

  }



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

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

  }

  

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

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

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



	cout << endl;

  }

  

  return 0;

}

// Fastest known solution for this problem: