Language: C++

/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

typedef long long ll;
typedef double db;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const db PI = acos(-1);
const ll MOD = 1e9 + 7, INF = LLONG_MAX;
const ll N = 1e5 + 10;

ll p[N], y[N];
string ans[N];
vector < pll > belong[N];

void test_case();

int main() {
	fast_io();
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	ll n, m;
	cin >> n >> m;
	for (ll i = 1; i <= m; ++i) {
		cin >> p[i] >> y[i];
		belong[p[i]].pb({y[i], i});
	}
	for (ll i = 0; i <= n; ++i) {
		sort(belong[i].begin(), belong[i].end());
		string pref = to_string(i);
		while (pref.size() != 6) {
			pref = "0" + pref;
		}
		for (ll j = 0; j < belong[i].size(); ++j) {
			string suff = to_string(j + 1);
			while (suff.size() != 6) {
				suff = "0" + suff;
			}
			ans[belong[i][j].second] = pref + suff;
		}
	}
	for (ll i = 1; i <= m; ++i) {
		cout << ans[i] << "\n";
	}
}/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

typedef long long ll;
typedef double db;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const db PI = acos(-1);
const ll MOD = 1e9 + 7, INF = LLONG_MAX;
const ll N = 1e5 + 10;

ll p[N], y[N];
string ans[N];
vector < pll > belong[N];

void test_case();

int main() {
	fast_io();
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	ll n, m;
	cin >> n >> m;
	for (ll i = 1; i <= m; ++i) {
		cin >> p[i] >> y[i];
		belong[p[i]].pb({y[i], i});
	}
	for (ll i = 0; i <= n; ++i) {
		sort(belong[i].begin(), belong[i].end());
		string pref = to_string(i);
		while (pref.size() != 6) {
			pref = "0" + pref;
		}
		for (ll j = 0; j < belong[i].size(); ++j) {
			string suff = to_string(j + 1);
			while (suff.size() != 6) {
				suff = "0" + suff;
			}
			ans[belong[i][j].second] = pref + suff;
		}
	}
	for (ll i = 1; i <= m; ++i) {
		cout << ans[i] << "\n";
	}
}

Compiler output:
a.cc:104:6: error: redefinition of 'template<class Arg1> void __f(const char*, Arg1&&)'
  104 | void __f(const char* name, Arg1&& arg1) {
      |      ^~~
a.cc:24:6: note: 'template<class Arg1> void __f(const char*, Arg1&&)' previously declared here
   24 | void __f(const char* name, Arg1&& arg1) {
      |      ^~~
a.cc:108:6: error: redefinition of 'template<class Arg1, class ... Args> void __f(const char*, Arg1&&, Args&& ...)'
  108 | void __f(const char* names, Arg1&& arg1, Args&&... args) {
      |      ^~~
a.cc:28:6: note: 'template<class Arg1, class ... Args> void __f(const char*, Arg1&&, Args&& ...)' previously declared here
   28 | void __f(const char* names, Arg1&& arg1, Args&&... args) {
      |      ^~~
a.cc:120:10: error: redefinition of 'const db PI'
  120 | const db PI = acos(-1);
      |          ^~
a.cc:40:10: note: 'const db PI' previously defined here
   40 | const db PI = acos(-1);
      |          ^~
a.cc:121:10: error: redefinition of 'const ll MOD'
  121 | const ll MOD = 1e9 + 7, INF = LLONG_MAX;
      |          ^~~
a.cc:41:10: note: 'const ll MOD' previously defined here
   41 | const ll MOD = 1e9 + 7, INF = LLONG_MAX;
      |          ^~~
a.cc:121:25: error: redefinition of 'const ll INF'
  121 | const ll MOD = 1e9 + 7, INF = LLONG_MAX;
      |                         ^~~
a.cc:41:25: note: 'const ll INF' previously defined here
   41 | const ll MOD = 1e9 + 7, INF = LLONG_MAX;
      |                         ^~~
a.cc:122:10: error: redefinition of 'const ll N'
  122 | const ll N = 1e5 + 10;
      |          ^
a.cc:42:10: note: 'const ll N' previously defined here
   42 | const ll N = 1e5 + 10;
      |          ^
a.cc:124:4: error: redefinition of 'll p [100010]'
  124 | ll p[N], y[N];
      |    ^
a.cc:44:4: note: 'll p [100010]' previously declared here
   44 | ll p[N], y[N];
      |    ^
a.cc:124:10: error: redefinition of 'll y [100010]'
  124 | ll p[N], y[N];
      |          ^
a.cc:44:10: note: 'll y [100010]' previously declared here
   44 | ll p[N], y[N];
      |          ^
a.cc:125:8: error: redefinition of 'std::string ans [100010]'
  125 | string ans[N];
      |        ^~~
a.cc:45:8: note: 'std::string ans [100010]' previously declared here
   45 | string ans[N];
      |        ^~~
a.cc:126:16: error: redefinition of 'std::vector<std::pair<long long int, long long int> > belong [100010]'
  126 | vector < pll > belong[N];
      |                ^~~~~~
a.cc:46:16: note: 'std::vector<std::pair<long long int, long long int> > belong [100010]' previously declared here
   46 | vector < pll > belong[N];
      |                ^~~~~~
a.cc:130:5: error: redefinition of 'int main()'
  130 | int main() {
      |     ^~~~
a.cc:50:5: note: 'int main()' previously defined here
   50 | int main() {
      |     ^~~~
a.cc:137:6: error: redefinition of 'void test_case()'
  137 | void test_case() {
      |      ^~~~~~~~~
a.cc:57:6: note: 'void test_case()' previously defined here
   57 | void test_case() {
      |      ^~~~~~~~~