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

    using namespace std;

    int main() {

      int a,b;

      string r,g,x;

      cin>>r;

      cin>>g;

      cin>>a>>b;

      cin>>x;

      if(x==r){

          a-=1;

      }

      else{

          b-=1;

      }

        cout<<a<<' '<<b;

     }

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

#include<string.h>

int main()

{

    int X,Y;



    char S[20];

    char T[20];

    char U[20];



    scanf("%s %s",S,T);

    scanf("%d %d",&X,&Y);

    scanf("%s",U);





    if(strcmp(S,U)==0)

    {





    X--;

    printf("%d %d",X,Y);

    }





  else

    {



    Y--;

    printf("%d %d",X,Y);

    }



    return 0;

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

using namespace std;



int main()

{

    string S, T, U;

    int A, B;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;

    if (U == S) {

        A-=1;

        cout << A<<" "<<B;

    }

    else if (U == T) {

        B-=1;

        cout << A<<" "<<B;

    }

    return 0;



}

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

#include<string.h>

int main()

{

    int X,Y;



    char S[20];

    char T[20];

    char U[20];



    scanf("%s %s",S,T);

    scanf("%d %d",&X,&Y);

    scanf("%s",U);





    if(strcmp(S,U)==0)

    {





    X--;

    printf("%d %d",X,Y);

    }





  else

    {



    Y--;

    printf("%d %d",X,Y);

    }



    return 0;

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

#include <string>

using namespace std;







int main()

{

    int A,B;

    string S,T,U;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;



    if(S==U){

            A = A-1;



    } else if(T==U){

       B = B-1;



    }

    cout << A << " " << B << endl;



    return 0;

}


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

#include<string.h>

int main()

{

    int X,Y;



    char S[20];

    char T[20];

    char U[20];



    scanf("%s %s",S,T);

    scanf("%d %d",&X,&Y);

    scanf("%s",U);





    if(strcmp(S,U)==0)

    {





    X--;

    printf("%d %d",X,Y);

    }





  else

    {



    Y--;

    printf("%d %d",X,Y);

    }



    return 0;

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



using namespace std;



int main()

{

    string s,t,u;

    int a,b;

    cin>>s>>t;

    cin>>a>>b;

    cin>>u;

    if(u==s)

        cout<<a-1<<" "<<b<<endl;

    else if(u==t)

        cout<<a<<" "<<b-1<<endl;



    return 0;

}


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

#include<string.h>

int main()

{

    int X,Y;



    char S[20];

    char T[20];

    char U[20];



    scanf("%s %s",S,T);

    scanf("%d %d",&X,&Y);

    scanf("%s",U);





    if(strcmp(S,U)==0)

    {





    X--;

    printf("%d %d",X,Y);

    }





  else

    {



    Y--;

    printf("%d %d",X,Y);

    }



    return 0;

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



using namespace std;



int main() {



   string color1,color2;

   int no1,no2;

   string color;

   cin>>color1>>color2>>no1>>no2>>color;

   if(color==color1){

       cout<<--no1<<" "<<no2<<endl;

   }

   else cout<<no1<<" "<<--no2<<endl;

    return 0;

}


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

#include<string.h>

int main()

{

    int X,Y;



    char S[20];

    char T[20];

    char U[20];



    scanf("%s %s",S,T);

    scanf("%d %d",&X,&Y);

    scanf("%s",U);





    if(strcmp(S,U)==0)

    {





    X--;

    printf("%d %d",X,Y);

    }





  else

    {



    Y--;

    printf("%d %d",X,Y);

    }



    return 0;

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

    using namespace std;

    int main() {

      int a,b;

      string r,g,x;

      cin>>r;

      cin>>g;

      cin>>a>>b;

      cin>>x;

      if(x==r){

          a-=1;

      }

      else{

          b-=1;

      }

        cout<<a<<' '<<b;

     }

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

#include <string.h>

int main()

{

	char color[15];

	char warna[15];

	char RGB [15];

	int A, B;

	

	scanf("%s %s", &color, &warna);

	scanf("%d %d", &A, &B);

	scanf("%s", &RGB);

	

	if (strcmp(RGB,warna)==0) printf("%d %d", A, B-1);

	if (strcmp(RGB,color)==0) printf("%d %d\n", A-1, B);

	

	return 0;

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

using namespace std;



int main()

{

    string S, T, U;

    int A, B;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;

    if (U == S) {

        A-=1;

        cout << A<<" "<<B;

    }

    else if (U == T) {

        B-=1;

        cout << A<<" "<<B;

    }

    return 0;



}

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

#include <string.h>

int main()

{

	char color[15];

	char warna[15];

	char RGB [15];

	int A, B;

	

	scanf("%s %s", &color, &warna);

	scanf("%d %d", &A, &B);

	scanf("%s", &RGB);

	

	if (strcmp(RGB,warna)==0) printf("%d %d", A, B-1);

	if (strcmp(RGB,color)==0) printf("%d %d\n", A-1, B);

	

	return 0;

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

#include <string>

using namespace std;







int main()

{

    int A,B;

    string S,T,U;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;



    if(S==U){

            A = A-1;



    } else if(T==U){

       B = B-1;



    }

    cout << A << " " << B << endl;



    return 0;

}


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

#include <string.h>

int main()

{

	char color[15];

	char warna[15];

	char RGB [15];

	int A, B;

	

	scanf("%s %s", &color, &warna);

	scanf("%d %d", &A, &B);

	scanf("%s", &RGB);

	

	if (strcmp(RGB,warna)==0) printf("%d %d", A, B-1);

	if (strcmp(RGB,color)==0) printf("%d %d\n", A-1, B);

	

	return 0;

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



using namespace std;



int main()

{

    string s,t,u;

    int a,b;

    cin>>s>>t;

    cin>>a>>b;

    cin>>u;

    if(u==s)

        cout<<a-1<<" "<<b<<endl;

    else if(u==t)

        cout<<a<<" "<<b-1<<endl;



    return 0;

}


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

#include <string.h>

int main()

{

	char color[15];

	char warna[15];

	char RGB [15];

	int A, B;

	

	scanf("%s %s", &color, &warna);

	scanf("%d %d", &A, &B);

	scanf("%s", &RGB);

	

	if (strcmp(RGB,warna)==0) printf("%d %d", A, B-1);

	if (strcmp(RGB,color)==0) printf("%d %d\n", A-1, B);

	

	return 0;

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



using namespace std;



int main() {



   string color1,color2;

   int no1,no2;

   string color;

   cin>>color1>>color2>>no1>>no2>>color;

   if(color==color1){

       cout<<--no1<<" "<<no2<<endl;

   }

   else cout<<no1<<" "<<--no2<<endl;

    return 0;

}


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

#include <string.h>

int main()

{

	char color[15];

	char warna[15];

	char RGB [15];

	int A, B;

	

	scanf("%s %s", &color, &warna);

	scanf("%d %d", &A, &B);

	scanf("%s", &RGB);

	

	if (strcmp(RGB,warna)==0) printf("%d %d", A, B-1);

	if (strcmp(RGB,color)==0) printf("%d %d\n", A-1, B);

	

	return 0;

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

    using namespace std;

    int main() {

      int a,b;

      string r,g,x;

      cin>>r;

      cin>>g;

      cin>>a>>b;

      cin>>x;

      if(x==r){

          a-=1;

      }

      else{

          b-=1;

      }

        cout<<a<<' '<<b;

     }

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

#include<string.h>

int main(){

	

	char S[15];

	char T[15];

	char U[15];

	

	int A;

	int B;

	

	scanf("%s %s",S,T);

	

	scanf("%d %d",&A,&B);

	

	scanf("%s",U);

	

	

	if(strcmp(U,S)==0){

		printf("%d %d\n",A-1,B);

	}

	else if(strcmp(U,T)==0){

		printf("%d %d\n",A,B-1);

	}

	

	return 0;

	

	

	

	

	

	

	

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

using namespace std;



int main()

{

    string S, T, U;

    int A, B;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;

    if (U == S) {

        A-=1;

        cout << A<<" "<<B;

    }

    else if (U == T) {

        B-=1;

        cout << A<<" "<<B;

    }

    return 0;



}

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

#include<string.h>

int main(){

	

	char S[15];

	char T[15];

	char U[15];

	

	int A;

	int B;

	

	scanf("%s %s",S,T);

	

	scanf("%d %d",&A,&B);

	

	scanf("%s",U);

	

	

	if(strcmp(U,S)==0){

		printf("%d %d\n",A-1,B);

	}

	else if(strcmp(U,T)==0){

		printf("%d %d\n",A,B-1);

	}

	

	return 0;

	

	

	

	

	

	

	

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

#include <string>

using namespace std;







int main()

{

    int A,B;

    string S,T,U;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;



    if(S==U){

            A = A-1;



    } else if(T==U){

       B = B-1;



    }

    cout << A << " " << B << endl;



    return 0;

}


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

#include<string.h>

int main(){

	

	char S[15];

	char T[15];

	char U[15];

	

	int A;

	int B;

	

	scanf("%s %s",S,T);

	

	scanf("%d %d",&A,&B);

	

	scanf("%s",U);

	

	

	if(strcmp(U,S)==0){

		printf("%d %d\n",A-1,B);

	}

	else if(strcmp(U,T)==0){

		printf("%d %d\n",A,B-1);

	}

	

	return 0;

	

	

	

	

	

	

	

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



using namespace std;



int main()

{

    string s,t,u;

    int a,b;

    cin>>s>>t;

    cin>>a>>b;

    cin>>u;

    if(u==s)

        cout<<a-1<<" "<<b<<endl;

    else if(u==t)

        cout<<a<<" "<<b-1<<endl;



    return 0;

}


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

#include<string.h>

int main(){

	

	char S[15];

	char T[15];

	char U[15];

	

	int A;

	int B;

	

	scanf("%s %s",S,T);

	

	scanf("%d %d",&A,&B);

	

	scanf("%s",U);

	

	

	if(strcmp(U,S)==0){

		printf("%d %d\n",A-1,B);

	}

	else if(strcmp(U,T)==0){

		printf("%d %d\n",A,B-1);

	}

	

	return 0;

	

	

	

	

	

	

	

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



using namespace std;



int main() {



   string color1,color2;

   int no1,no2;

   string color;

   cin>>color1>>color2>>no1>>no2>>color;

   if(color==color1){

       cout<<--no1<<" "<<no2<<endl;

   }

   else cout<<no1<<" "<<--no2<<endl;

    return 0;

}


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

#include<string.h>

int main(){

	

	char S[15];

	char T[15];

	char U[15];

	

	int A;

	int B;

	

	scanf("%s %s",S,T);

	

	scanf("%d %d",&A,&B);

	

	scanf("%s",U);

	

	

	if(strcmp(U,S)==0){

		printf("%d %d\n",A-1,B);

	}

	else if(strcmp(U,T)==0){

		printf("%d %d\n",A,B-1);

	}

	

	return 0;

	

	

	

	

	

	

	

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

    using namespace std;

    int main() {

      int a,b;

      string r,g,x;

      cin>>r;

      cin>>g;

      cin>>a>>b;

      cin>>x;

      if(x==r){

          a-=1;

      }

      else{

          b-=1;

      }

        cout<<a<<' '<<b;

     }

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

#include<string.h>



int main()

{

	char x[15], y[15], z[15];

	int i,j;

	scanf("%s %s", &x, &y);

	getchar();

	scanf("%d %d", &i, &j);

	getchar();

	scanf("%s", &z);

	

	if(strcmp(x, z)==0){

		printf("%d %d", i-1 , j);

	}

	else if(strcmp(y, z)==0){

		printf("%d %d", i, j-1);

	}

	return 0;

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

using namespace std;



int main()

{

    string S, T, U;

    int A, B;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;

    if (U == S) {

        A-=1;

        cout << A<<" "<<B;

    }

    else if (U == T) {

        B-=1;

        cout << A<<" "<<B;

    }

    return 0;



}

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

#include<string.h>



int main()

{

	char x[15], y[15], z[15];

	int i,j;

	scanf("%s %s", &x, &y);

	getchar();

	scanf("%d %d", &i, &j);

	getchar();

	scanf("%s", &z);

	

	if(strcmp(x, z)==0){

		printf("%d %d", i-1 , j);

	}

	else if(strcmp(y, z)==0){

		printf("%d %d", i, j-1);

	}

	return 0;

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

#include <string>

using namespace std;







int main()

{

    int A,B;

    string S,T,U;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;



    if(S==U){

            A = A-1;



    } else if(T==U){

       B = B-1;



    }

    cout << A << " " << B << endl;



    return 0;

}


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

#include<string.h>



int main()

{

	char x[15], y[15], z[15];

	int i,j;

	scanf("%s %s", &x, &y);

	getchar();

	scanf("%d %d", &i, &j);

	getchar();

	scanf("%s", &z);

	

	if(strcmp(x, z)==0){

		printf("%d %d", i-1 , j);

	}

	else if(strcmp(y, z)==0){

		printf("%d %d", i, j-1);

	}

	return 0;

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



using namespace std;



int main()

{

    string s,t,u;

    int a,b;

    cin>>s>>t;

    cin>>a>>b;

    cin>>u;

    if(u==s)

        cout<<a-1<<" "<<b<<endl;

    else if(u==t)

        cout<<a<<" "<<b-1<<endl;



    return 0;

}


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

#include<string.h>



int main()

{

	char x[15], y[15], z[15];

	int i,j;

	scanf("%s %s", &x, &y);

	getchar();

	scanf("%d %d", &i, &j);

	getchar();

	scanf("%s", &z);

	

	if(strcmp(x, z)==0){

		printf("%d %d", i-1 , j);

	}

	else if(strcmp(y, z)==0){

		printf("%d %d", i, j-1);

	}

	return 0;

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



using namespace std;



int main() {



   string color1,color2;

   int no1,no2;

   string color;

   cin>>color1>>color2>>no1>>no2>>color;

   if(color==color1){

       cout<<--no1<<" "<<no2<<endl;

   }

   else cout<<no1<<" "<<--no2<<endl;

    return 0;

}


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

#include<string.h>



int main()

{

	char x[15], y[15], z[15];

	int i,j;

	scanf("%s %s", &x, &y);

	getchar();

	scanf("%d %d", &i, &j);

	getchar();

	scanf("%s", &z);

	

	if(strcmp(x, z)==0){

		printf("%d %d", i-1 , j);

	}

	else if(strcmp(y, z)==0){

		printf("%d %d", i, j-1);

	}

	return 0;

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

    using namespace std;

    int main() {

      int a,b;

      string r,g,x;

      cin>>r;

      cin>>g;

      cin>>a>>b;

      cin>>x;

      if(x==r){

          a-=1;

      }

      else{

          b-=1;

      }

        cout<<a<<' '<<b;

     }

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

#include <string.h>



int main(){

    char S[15], T[15], U[15];

    int a, b;

    

    scanf("%s %s", S, T);

    scanf("%d %d", &a, &b);

    scanf("%s", U);

    

    (strcmp(U, S) == 0) ? a-- : b--;

    printf("%d %d", a, b);

    

    return 0;



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

using namespace std;



int main()

{

    string S, T, U;

    int A, B;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;

    if (U == S) {

        A-=1;

        cout << A<<" "<<B;

    }

    else if (U == T) {

        B-=1;

        cout << A<<" "<<B;

    }

    return 0;



}

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

#include <string.h>



int main(){

    char S[15], T[15], U[15];

    int a, b;

    

    scanf("%s %s", S, T);

    scanf("%d %d", &a, &b);

    scanf("%s", U);

    

    (strcmp(U, S) == 0) ? a-- : b--;

    printf("%d %d", a, b);

    

    return 0;



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

#include <string>

using namespace std;







int main()

{

    int A,B;

    string S,T,U;

    cin >> S >> T;

    cin >> A >> B;

    cin >> U;



    if(S==U){

            A = A-1;



    } else if(T==U){

       B = B-1;



    }

    cout << A << " " << B << endl;



    return 0;

}


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

#include <string.h>



int main(){

    char S[15], T[15], U[15];

    int a, b;

    

    scanf("%s %s", S, T);

    scanf("%d %d", &a, &b);

    scanf("%s", U);

    

    (strcmp(U, S) == 0) ? a-- : b--;

    printf("%d %d", a, b);

    

    return 0;



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



using namespace std;



int main()

{

    string s,t,u;

    int a,b;

    cin>>s>>t;

    cin>>a>>b;

    cin>>u;

    if(u==s)

        cout<<a-1<<" "<<b<<endl;

    else if(u==t)

        cout<<a<<" "<<b-1<<endl;



    return 0;

}


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

#include <string.h>



int main(){

    char S[15], T[15], U[15];

    int a, b;

    

    scanf("%s %s", S, T);

    scanf("%d %d", &a, &b);

    scanf("%s", U);

    

    (strcmp(U, S) == 0) ? a-- : b--;

    printf("%d %d", a, b);

    

    return 0;



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



using namespace std;



int main() {



   string color1,color2;

   int no1,no2;

   string color;

   cin>>color1>>color2>>no1>>no2>>color;

   if(color==color1){

       cout<<--no1<<" "<<no2<<endl;

   }

   else cout<<no1<<" "<<--no2<<endl;

    return 0;

}


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

#include <string.h>



int main(){

    char S[15], T[15], U[15];

    int a, b;

    

    scanf("%s %s", S, T);

    scanf("%d %d", &a, &b);

    scanf("%s", U);

    

    (strcmp(U, S) == 0) ? a-- : b--;

    printf("%d %d", a, b);

    

    return 0;



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

#include <iostream>



using namespace std;



int main()

{

	int N, M;



	char A, B, C;



	while (true)

	{

		cin >> N;



		if (N == 0) { break; }



		map<char, char> converse;



		for (char i = '0'; i <= 'z'; i++)

		{

			converse[i] = i;

		}



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

		{

			cin >> A >> B;



			converse[A] = B;

		}



		cin >> M;



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

		{

			cin >> C;



			cout << converse[C];

		}



		cout << endl;

	}



	return 0;

}

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

#include <cstring>

int n, m; char e[261], f, g;

int main() {

	while(scanf("%d\n", &n), n) {

		for(int i = 0; i < 256; i++) e[i] = i;

		for(int i = 0; i < n; i++) scanf("%c %c\n", &f, &g), e[f] = g;

		scanf("%d\n", &m);

		for(int i = 0; i < m; i++) scanf("%c\n", &f), printf("%c", e[f]);

		printf("\n");

	}

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

#include <map>

#include <string>



using namespace std;



int main() {

	int n, m;

	while (cin >> n, n) {

		char a, b;

		string str;

		map<char, char> to;

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

			cin >> a >> b;

			to[a] = b;

		}

		cin >> m;

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

			cin >> a;

			if (to[a]) a = to[a];

			str += a;

		}

		cout << str << endl;

	}

	return 0;

}

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



int main() {

	char trans[256];

	char c, c2, str[10];

	long n, m, i;



	while (scanf("%ld", &n), n) {

		for (i = 0; i < 256; ++i)

			trans[i] = i;



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

			scanf("%s", str); c = str[0];

			scanf("%s", str); c2 = str[0];

			trans[c] = c2;

		}



		scanf("%ld", &m);



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

			scanf("%s", str); c = str[0];

			printf("%c", trans[c]);

		}

		puts("");

	}



	return 0;

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

#include<iostream>

#include<algorithm>

#include<stack>

#include<cmath>

#include<vector>

using namespace std;

int n,m;

int p[100005]; 

int y[100005];

vector<int>v[100005];

int main(){

	scanf("%d%d",&n,&m);

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

		scanf("%d%d",&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=1;i<=m;i++){

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

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

		printf("%06d\n",k);

	}

	return 0;

}

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

using namespace std;

#define LL long long

int a[100005]={0};

typedef pair<long long,long long> o;

int main()

{

	 int np,n;

	 cin>>np>>n;

	 map<long long,long long>m;

	 vector<long long>v[np+5];

	 vector<o>v1;

	

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

	 { 

	 	int y,p;

	 	cin>>p>>y;

	o pp (p,y);

	 	v[p].push_back(y);

	 	v1.push_back(pp);

	 }

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

	 {

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

	 }

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

	 {

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

	    {

	    	m[v[i][j]]=j+1;

		}

	 }

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

	{  o ppp=v1[i];

		printf("%06lld%06lld\n",ppp.first,m[ppp.second]);

	}

	 

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

#include<iostream>

#include<algorithm>

#include<stack>

#include<cmath>

#include<vector>

using namespace std;

int n,m;

int p[100005]; 

int y[100005];

vector<int>v[100005];

int main(){

	scanf("%d%d",&n,&m);

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

		scanf("%d%d",&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=1;i<=m;i++){

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

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

		printf("%06d\n",k);

	}

	return 0;

}

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

#include<algorithm>

#include<cstdio>

using namespace std;

struct node{

    int city;

    long long num;

    int no;

    int i;

}a[100000+5];

bool cmp(struct node A,struct node B){

    if(A.city < B.city){

        return true;

    }else if(A.city == B.city){

        if(A.num < B.num){

            return true;

        }else{

            return false;

        }

    }else {

        return false;

    }

};

bool cmp1(struct node A,struct node B){

    if(A.i < B.i){

        return true;

    }else {

        return false;

    }

}

int main(){

    int N,M;

    cin>>N>>M;

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

        a[i].i = i;

        int city,num;

        cin>>city>>num;

        a[i].city = city;

        a[i].num = num;

    }

    sort(a,a+M,cmp);

    int flag = 1;

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

        if(i == 0){

            a[i].no = flag;

        }else if(a[i].city != a[i-1].city){

            flag = 1;

        }

        a[i].no = flag;

        flag++;

    }

    sort(a,a+M,cmp1);

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

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

    }

    return 0;

}