jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1)*(n - w + 1) << endl;
	return 0;
}
//  [cpp]
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}


void MAIN() {
    int H, W, N;
    scanf("%d%d%d", &N, &H, &W);
    int ans = (N - H + 1) * (N - W + 1);
    printf("%d\n", ans);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}
//  [cpp]
#include <cstring>
#include <vector>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	int N, H, W;
	cin >> N >> H >> W;
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			int startx = i;
			int starty = j;
			bool flag = true;
			for (int k = startx; k<startx + H; k++)
			{
				if (k >= N)flag = false;
				for (int t = starty; t < starty + W; t++) {
					if (t >= N)flag = false;
				}
			}
			if (flag)cnt++;
		}
	}
	cout << cnt;
}
//  [cpp]
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,d;cin>>a>>b>>d;
  cout<<(a-d+1)*(a-b+1);
}
//  [cpp]
#include <iostream>
using namespace std;

int main(){
    int N=0,H=0,W=0;
    cin >>N >>H >>W;
    
    cout << (N-H+1)*(N-W+1) << endl;


}
//  [c]
#include <stdio.h>

int main(void){

  int n,h,w;
  scanf("%d %d %d", &n, &h, &w);
  printf("%d\n", (n-h+1)*(n-w+1));

  return 0;
}
//  [c]
#include <stdio.h>
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d",(a-b+1)*(a-c+1));
	return 0;
}
//  [c]
#include <stdio.h>
int main() {
	int n, h, w;
	scanf("%d%d%d", &n, &h, &w);
	printf("%d\n", (n - h + 1) * (n - w + 1));
	return 0;
}
//  [c]
int N, W, H;
int main(){
  scanf("%d%d%d", &N, &H, &W);
  printf("%d\n", (N-W+1)*(N-H+1));
}
//  [c]
#include <stdio.h>

int main(){
  int N,H,W;
  scanf("%d\n%d\n%d",&N,&H,&W);
  printf("%d\n",(N-H+1)*(N-W+1));
  return 0;
}
//  [c]
#include <stdio.h>

int main (void)
{
    int n,h,w;
    scanf("%d",&n);
    scanf("%d",&h);
    scanf("%d",&w);
    printf("%d\n",(n-h+1)*(n-w+1));
    return 0;
}
//  [javascript]
function Main(input) {
	input = input.split("\n").map(Number)
	console.log((input[0]+1-input[1])*(input[0]+1-input[2]));
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function main(input) {
  var args = input.split('\n');
  var N = parseInt(args[0],10);
  var H = parseInt(args[1],10);
  var W = parseInt(args[2],10);
  var h = N - H + 1;
  var w = N - W + 1;
  console.log(h * w);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var N = parseInt(input[0][0], 10);
	var H = parseInt(input[1][0], 10);
	var W = parseInt(input[2][0], 10);
	console.log((N - H + 1) * (N - W + 1));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var _splitNum = splitNum(input),
      _splitNum2 = _slicedToArray(_splitNum, 3),
      N = _splitNum2[0],
      H = _splitNum2[1],
      W = _splitNum2[2];

  var result = (N - H + 1) * (N - W + 1);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}
//  [javascript]
function main(arg) {
	arg = arg.split("\n")
	var N = Number(arg[0])
	var H = Number(arg[1])
	var W = Number(arg[2])

	var w = N - W + 1
	var h = N - H + 1 
	console.log(w * h)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  N= parseInt(input[0]);
  H= parseInt(input[1]);
  W= parseInt(input[2]);
  var ans=(N-H+1)*(N-W+1);
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import "fmt"

func main() {
	var n, h, w int
	fmt.Scan(&n, &h, &w)

	fmt.Println((n - h + 1) * (n - w + 1))
}
//  [go]
package main

import "fmt"

func main() {
    var n, h, w int
    fmt.Scan(&n, &h, &w)

    fmt.Println( (n-w+1)*(n-h+1) )
    return
}
//  [go]
package main

import "fmt"

func main() {
	var n, h, w int
	fmt.Scan(&n)
	fmt.Scan(&h)
	fmt.Scan(&w)
	fmt.Println((n - h + 1) * (n - w + 1))
}
//  [ruby]
n = gets.to_i
h = gets.to_i
w = gets.to_i
puts (n + 1 - h) * (n + 1 - w)
//  [ruby]
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
H=gets.to_i
W=gets.to_i
puts (N-H+1)*(N-W+1)
//  [ruby]
N=gets.to_i
H=gets.to_i
W=gets.to_i
puts (N-H+1)*(N-W+1)
//  [ruby]
n,h,w=`dd`.split.map &:to_i
puts (n-h+1)*(n-w+1)
//  [ruby]
n = gets.to_i
h = gets.to_i
w = gets.to_i

puts (n - h + 1) * (n - w + 1)
//  [ruby]
n = gets.to_i
h = gets.to_i
w = gets.to_i
p (n-h+1)*(n-w+1)
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let h: usize = read();
    let w: usize = read();

    let ans = (n + 1 - h) * (n + 1 - w);
    println!("{}", ans);
}
//  [rust]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut scan = Scanner::new(cin);

    let n = scan.read::<i64>();
    let h = scan.read::<i64>();
    let w = scan.read::<i64>();
    println!("{}", (n - h + 1) * (n - w + 1));
}

// region template
#[allow(dead_code)]
fn uz(i: i32) -> usize { i as usize }

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: i32) -> Vec<T> {
        let mut ret = vec![];
        for _ in 0..n { ret.push(self.read::<T>()) }
        ret
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion
//  [rust]
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let h:u32 = read();
    let w:u32 = read();

    println!("{}", (n-h+1)*(n-w+1));

}
//  [rust]
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: u64 = input();
    let h: u64 = input();
    let w: u64 = input();
    println!("{}", (n - h  + 1) * (n - w + 1));
}
//  [rust]
fn main() {
    proconio::input! {
    a:[isize;3],
    }
    println!("{}",(a[0]-a[1]+1)*(a[0]-a[2]+1))
}
//  [rust]
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        a: i64, b: i64, c: i64,
    }
    println!("{}", (a - b + 1) * (a - c + 1));
}
//  [swift]
let N=Int(readLine()!)!+1
print((N-Int(readLine()!)!)*(N-Int(readLine()!)!))
//  [typescript]
function solve(N:number, A: number[]):number{
  const f=fact(N);
  let sum=0;
  for(let i=0;i<N;i++){
    sum+=mul(A[i],sub(add(tasuyatu(N-i),tasuyatu(i+1)),1));
  }
  sum=mul(sum,f);
  return sum;
}
function Main(raw: string) {
  const input = raw.split("\n");
  const N = parseInt(input[0], 10);
  const H = parseInt(input[1], 10);
  const W = parseInt(input[2], 10);

  //出力
  console.log("%d", (N-H+1)*(N-W+1));
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = parseInt(xs[0]);
   let W = parseInt(xs[1]);
   let H = parseInt(xs[2]);
   console.log((N - H + 1) * (N - W + 1));
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [python]
import sys
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *PY = map(int, read().split())
    city = [(p, y, i) for i, (p, y) in enumerate(zip(*[iter(PY)] * 2))]

    city.sort(key=itemgetter(1))

    counter = [0] * (N + 1)
    ans = [0] * M
    for p, y, i in city:
        counter[p] += 1
        ans[i] = f"{p:>06}{counter[p]:>06}"

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()
//  [python]
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, M = in_nn()
    t = in_na()
    PY = list(zip(t, t))

    d = defaultdict(list)

    for i in range(M):
        p, y = PY[i]
        d[p].append(y)

    ans = dict()
    for k, v in d.items():
        v.sort()
        for i, y in enumerate(v):
            ans[(k, y)] = '{:0>6}{:0>6}'.format(k, i + 1)

    for i in range(M):
        p, y = PY[i]
        print(ans[(p, y)])


if __name__ == '__main__':
    main()
//  [python]
import sys


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    results = {}
    p_list = []
    y_list = []
    cnt = 0
    for i in range(m):
        p, y = map(int, input().split())
        p_list.append(p)
        y_list.append(y)
        if results.get(p) is None:
            results[p] = [y]
        else:
            results[p].append(y)
    for i, p in results.items():
        p_sorted = sorted(p)
        results[i] = p_sorted

    for i, p in enumerate(p_list):
        import bisect
        print('{:006}'.format(p) + '{:006}'.format(bisect.bisect_left(results[p], y_list[i]) + 1))


if __name__ == "__main__":
    main()
//  [python]
import numpy as np


n, m = map(int, input().split())
py = [list(map(int, input().split())) for _ in range(m)]
p = [[] for _ in range(n)]
for _p, _y in py:
    p[_p - 1].append(_y)
for i in range(n):
    p[i] = np.argsort(np.argsort(p[i]))

counter = [0 for _ in range(n)]
for _p, _y in py:
    t = "{:06}{:06}".format(_p, p[_p - 1][counter[_p - 1]] + 1)
    print(t)
    counter[_p - 1] += 1
//  [python]
import numpy as np

N,M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
order = [[] for _ in range(N)]
for p,y in X:
    order[p-1].append(y)
#X = np.array(X, dtype=int)
for i in range(N):
    order[i] = np.argsort(np.argsort(order[i]))
cnts = [0 for _ in range(N)]
for i in range(M):
    p = X[i][0]
    print('{:06}{:06}'.format(p, order[p-1][cnts[p-1]]+1) )
    cnts[p-1] += 1
//  [python]
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def cmp_vec(u,v):   # u < v なる必要条件を記す
    if u[1] < v[1]:
        return  1
    elif u[1] == v[1]:
        if u[2] < v[2]:
            return 1
        elif u[2]==v[2]:
            return 0
        else:
            return -1
    else:
        return -1

def main():
    #
    n,m = map(int,input().strip().split())  # 市 in 県  # n個の県，m個の市
    l=[]
    for i in range(m):
        p,y = map(int,input().strip().split()) # 市iは県piに属しyi年に誕生した
        p = str(p).zfill(6) # p-=1 # i (y,p) 
        l.append(list((i,p,y)))
    l.sort(key=functools.cmp_to_key(cmp_vec),reverse = True)

    #
    eprint('l (i,p,y)',end=':\n')
    eprint(l)

    #
    cntr=1
    for i in range(m):
        if i>0 and l[i][1] != l[i-1][1]:
            cntr=1
        l[i][2] = str(cntr).zfill(6)
        cntr+=1

    #
    l.sort(key=lambda x:x[0])
    for xx in l:
        print(xx[1]+xx[2])
    #
    # eprint('l (i,p,y)',end=':\n')
    # eprint(l)
    # aaa=["asdfa",32, 15.3, True]
    # eprint('aaa ',end=':\n')
    # eprint(aaa)

if __name__ == '__main__':
    main()
//  [java]
import java.util.*;

/**
 * year -> orderの変換を作る
 * 
 * @author glycine
 *
 */
public class Main {
	private static class Node {
		int p;
		long y;
		int order = -1;

		public Node(int p, long y) {
			this.p = p;
			this.y = y;
		}
	}

	int N, M;
	int[] indexes;
	List<Node> nodes;
	Map<Long, Node> maps = new TreeMap<>();
	List<String> results;

	public Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		M = in.nextInt();
		indexes = new int[N];
		Arrays.fill(indexes, 0);
		nodes = new ArrayList<>(M);
		for (int i = 0; i < M; ++i) {
			int p = in.nextInt();
			long y = in.nextLong();
			Node node = new Node(p, y);
			nodes.add(node);
			maps.put(node.y, node);
		}
		in.close();
	}

	private void calc() {
		for (Node city : maps.values()) {
			int i = city.p - 1;
			++indexes[i];
			city.order = indexes[i];
		}
	}

	private void show() {
		for (int i = 0; i < nodes.size(); ++i) {
			Node node = nodes.get(i);
			int p = node.p;
			int order = node.order;
			String line = String.format("%06d%06d", p, order);
			System.out.println(line);
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		ins.show();
	}
}
//  [java]
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] ps = new int[m];
        int[] ys = new int[m];
        HashMap<Integer, Map<Integer, Integer>> pyMap = new HashMap<>(n);
        for (int i = 0; i < m; i++) {
            ps[i] = sc.nextInt();
            ys[i] = sc.nextInt();
            pyMap.computeIfAbsent(ps[i], (e) -> new TreeMap<Integer, Integer>()).put(ys[i], i);
        }

        String[] ans = new String[m];
        for (Entry<Integer, Map<Integer, Integer>> e : pyMap.entrySet()) {
            int index = 1;
            for (Entry<Integer, Integer> y : e.getValue().entrySet()) {
                ans[y.getValue()] = String.format("%06d%06d", e.getKey(), index++);
            }
        }

        Arrays.stream(ans).forEach(System.out::println);
    }
}
//  [java]
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int areaNum = sc.nextInt();
		int cityNum = sc.nextInt();
		
		List<Set<City>> l = new ArrayList<Set<City>>();
		
		for(int i = 0; i < areaNum; i++) {
			l.add(new TreeSet<City>(new Comparator<City>(){  
				 public int compare(City c1, City c2) {           
				        return c1.getTime()-c2.getTime();//降序排列  
				    } 
			}));
		}
		
		for(int i = 0; i < cityNum; i++) {
			int area = sc.nextInt();
			int time = sc.nextInt();
			l.get(area-1).add(new City(area-1, time, i));
		}
		
		Set<City> result = new TreeSet<City>(new Comparator<City>(){  
			 public int compare(City c1, City c2) {           
			        return c1.getOrder()-c2.getOrder();//降序排列  
			    } 
		});
		
		for(int i = 0; i < areaNum; i++){
			int j = 1;
//			if(l.get(i).size())
			for(Object c : l.get(i)){
				City c1 = (City)c;
				c1.setCode(formatNum(c1.getArea()+1, j));
				j++;
				result.add(c1);
			}
		}
		
		for(City c : result) {
			System.out.println(c.getCode());
		}
		
	}
	
	 
	
	private static String formatNum(int area, int order){
		String areaC = String.format("%06d", area);
		String timeC = String.format("%06d", order);
		return areaC+timeC;
	}
	
	static class City {
		private int time;
		private int area;
		private int order;
		private String code;
		public City( int area, int time, int order) {
			super();
			this.time = time;
			this.area = area;
			this.order = order;
		}
		
		
		
		public int getTime() {
			return time;
		}
		public void setTime(int time) {
			this.time = time;
		}
		public int getArea() {
			return area;
		}
		public void setArea(int area) {
			this.area = area;
		}
		public int getOrder() {
			return order;
		}
		public void setOrder(int order) {
			this.order = order;
		}
		
		public String getCode() {
			return code;
		}
		public void setCode(String code) {
			this.code = code;
		}
		
	}
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#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';
}

ll tmp[100001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	rep(k, 4) {
		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)i << 32) + getint();
	}
	pakuri_sort(M, S);

	rep(i, M) {
		int j = S[i] >> 32;
		tmp[j] = ++PK[P[j]];
	}
	rep(i, M) putkotae(P[i], tmp[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> city(M);
    vector<vector<int>> Pre(N,vector<int>(0));
    REP(i,M){
        cin >> city[i].first;
        cin >> city[i].second;
        city[i].first--;
        Pre[city[i].first].push_back(city[i].second);
    }
    REP(i,N)sort(Pre[i].begin(),Pre[i].end());
    REP(i,M){
        for(int l = 0;;l++){
            if(city[i].second == Pre[city[i].first][l]){
                city[i].second = l+1;
                break;
            }
        }
    }
    vector<string> zero(6);
    zero[0] = "";
    REP(i,5)zero[i+1] = zero[i] + "0";
    REP(i,M){
        cout << zero[6 - to_string(city[i].first+1).size()];
        cout << city[i].first + 1;
        cout << zero[6 - to_string(city[i].second).size()];
        cout << city[i].second<< "\n";
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
using pl = pair<ll,ll>;

signed main(){
	ll n,m; cin>>n>>m;
	vvl v(n,vl(0));
	vector<pl> vp(m);
	rep(i,0,m){
		ll a,b; cin>>a>>b;
		//cout<<a<<endl;
		vp[i]=make_pair(a,b);
		--a;
		v[a].push_back(b);
	}
	rep(i,0,n)if(v[i].size()>0)sort(all(v[i]));
	rep(i,0,m){
		//cout<<'a';
		ll a,b; tie(a,b)=vp[i];
		ll j=1;
		rep(k,0,v[a-1].size()){
			//cout<<v[a-1][k];
			if(v[a-1][k]==b){
				j=k+1;
				break;
			}
		}
//		cout<<endl;
		string s=to_string(a);
		rep(i,0,6-s.size())cout<<0;
		cout<<a;
		string t=to_string(j);
		rep(i,0,6-t.size())cout<<0;
		cout<<j<<endl;
	}
		
	
	
	
	return 0;
}
//  [cpp]
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll N, M;

    cin >> N >> M;

    vector<p> C, ans;
    vector<vector<ll>> H(N + 1);

    ll P, Y;

    rep(i, M) {
        cin >> P >> Y;
        C.emplace_back(P, Y);
        H[P].push_back(Y);
    }

    rep(i, N + 1) {
        sort(H[i].begin(), H[i].end());
    }


    rep(i, M) {
        P = C[i].first;      
        Y = find(H[P].begin(), H[P].end(), C[i].second) - H[P].begin() + 1;
        ans.emplace_back(P, Y);
    }

    char fillSaved = cout.fill('0');

    rep(i, M) {
        cout << setw(6) << ans[i].first << setw(6) << ans[i].second << endl;
    }

    cout.fill(fillSaved);

    return 0;
}



ll gcd(ll a, ll b) {
    if (a % b == 0)return(b);
    else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
//  [c]
// AtCoder ABC113: C - ID
// 2020.1.29 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i, k; char b[30];

	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	k = 6 - i;
	while (k--) pc('0');
	while (i--) pc(b[i]);

}

#define MAX 100005
typedef struct { int id; ll n; } T;
T t[MAX]; int M;

void Usort(T *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	ll t1[1 << B], t2[1 << B];
	
	T *tmp = malloc(n * sizeof(T));	
	for (k = 0; k < 8; ++k) {  // for 64ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i].n >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i].n >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i].n >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i].n >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
// for (i = 0; i < n; ++i) printf("[%d] %lld\n", i, a[i]);
}

int ap[MAX], ax[MAX];

int main()
{
	int i, N, P, Y, x;
	
	N = in(), M = in();
	for (i = 1; i <= M; ++i) {
		P = in(), Y = in();
		t[i].id = i, t[i].n = ((ll)P << 32) | Y;
		ap[i] = P;
	}
	Usort(t+1, M);
	for (i = 1; i <= M; ++i) {
		if ((t[i].n >> 32) != (t[i-1].n >> 32)) ax[t[i].id] = x = 1;
		else ax[t[i].id] = ++x;
	}
	for (i = 1; i <= M; ++i) {
		out(ap[i]), out(ax[i]), pc('\n');
	}
	return 0;
}
//  [c]
// AtCoder ABC113: C - ID
// 2020.1.29 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i, k; char b[30];

	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	k = 6 - i;
	while (k--) pc('0');
	while (i--) pc(b[i]);

}

#define MAX 100005
typedef struct { int id; ll n; int p, x; } T;
T t[MAX]; int M;

void Usort(T *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	ll t1[1 << B], t2[1 << B];
	
	T *tmp = malloc(n * sizeof(T));	
	for (k = 0; k < 8; ++k) {  // for 64ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i].n >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i].n >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i].n >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i].n >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
// for (i = 0; i < n; ++i) printf("[%d] %lld\n", i, a[i]);
}

int ap[MAX], ax[MAX];

int main()
{
	int i, N, P, Y;
	
	N = in(), M = in();
	for (i = 1; i <= M; ++i) {
		P = in(), Y = in();
		t[i].id = i, t[i].n = ((ll)P << 32) | Y, t[i].p = P;
		ap[i] = P;
	}
	Usort(t+1, M);
	for (i = 1; i <= M; ++i) {
		if (t[i].p != t[i-1].p) ax[t[i].id] = t[i].x = 1;
		else ax[t[i].id] = t[i].x = t[i-1].x+1;
	}
	for (i = 1; i <= M; ++i) {
		out(ap[i]), out(ax[i]), pc('\n');
	}
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

#define M 100000

int pp[M], yy[M];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return pp[i] != pp[j] ? pp[i] - pp[j] : yy[i] - yy[j];
}

void initialize(char *s, int p, int x) {
	int i;

	for (i = 11; i >= 0; i--)
		if (i < 6 && p > 0)
			s[i] = (p % 10) + '0', p /= 10;
		else if (i >= 6 && x > 0)
			s[i] = (x % 10) + '0', x /= 10;
		else
			s[i] = '0';
}

int main() {
	static int ii[M];
	static char id[M][13];
	int n, m, i, x;

	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &pp[i], &yy[i]);
		ii[i] = i;
	}
	qsort(ii, m, sizeof *ii, compare);
	for (i = 0, x = 1; i < m; i++, x = i > 0 && pp[ii[i]] != pp[ii[i - 1]] ? 1 : x + 1)
		initialize(id[ii[i]], pp[ii[i]], x);
	for (i = 0; i < m; i++)
		printf("%s\n", id[i]);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long number;
	long prefecture;
  long year;
  long id;
} S_CITY;

int cmpAscPre(const void * n1, const void * n2) {
	if (((S_CITY *)n1)->prefecture > ((S_CITY *)n2)->prefecture) {
		return 1;
	}
	else if (((S_CITY *)n1)->prefecture < ((S_CITY *)n2)->prefecture) {
		return -1;
	}
	else {
		if (((S_CITY *)n1)->year > ((S_CITY *)n2)->year) {
      return 1;
    }
    else if (((S_CITY *)n1)->year < ((S_CITY *)n2)->year) {
      return -1;
    }
    else {
      return 0;
    }
	}
}

int cmpAscNum(const void * n1, const void * n2) {
	if (((S_CITY *)n1)->number > ((S_CITY *)n2)->number) {
		return 1;
	}
	else if (((S_CITY *)n1)->number < ((S_CITY *)n2)->number) {
		return -1;
	}
	else {
		return 0;
	}
}

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  S_CITY cities[m];
  for (long i = 0; i < m; i++) {
    cities[i].number = i;
    scanf("%ld %ld", &cities[i].prefecture, &cities[i].year);
  }
  qsort(cities, m, sizeof(S_CITY), cmpAscPre);
  long latter = 1;
  cities[0].id = 1;
  for (long i = 1; i < m; i++) {
    if (cities[i].prefecture == cities[i-1].prefecture) {
      latter++;
    } else {
      latter = 1;
    }
    cities[i].id = latter;
  }
  qsort(cities, m, sizeof(S_CITY), cmpAscNum);
  int id_12[12];
  long former;
  for (long i = 0; i < m; i++) {
    former = cities[i].prefecture;
    latter = cities[i].id;
    for (int j = 5; j >= 0; j--) {
      id_12[j] = former%10;
      former /= 10;
    }
    for (int j = 11; j >= 6; j--) {
      id_12[j] = latter%10;
      latter /= 10;
    }
    for (int j = 0; j < 12; j++) {
      printf("%d", id_12[j]);
    }
    printf("\n");
  }

  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct {
  int num;
  int P;
  long long int Y;
  int y;
} bigint;

int cmp( const void *p, const void *q ) {
  if(((bigint*)p)->Y - ((bigint*)q)->Y > 0){
    return 1;
  }else{
    return -1;
  }
}

int cmp2( const void *p, const void *q ) {
    return ((bigint*)p)->num - ((bigint*)q)->num;
}

void sixint(int N){
  int i;
  int k[6];

  for(i=5;i>=0;i--){
    k[i]=N%10;
    N=(int)N/10;
  }
  
  for(i=0;i<6;i++){
    printf("%d",k[i]);
  }
}

int main(){
  int N,M,i;
  scanf("%d%d",&N,&M);
  bigint X[M];
  for(i=0;i<M;i++){
    scanf("%d%lld",&X[i].P,&X[i].Y);
    X[i].num=i;
  }
  qsort(X, M, sizeof(bigint), cmp);
  int c_P[N+1];
  for(i=0;i<N+1;i++){
    c_P[i]=1;
  }
  for(i=0;i<M;i++){
    X[i].y = c_P[X[i].P];
    c_P[X[i].P]=c_P[X[i].P]+1;
  }
  qsort(X, M, sizeof(bigint), cmp2 );
  for(i=0;i<M;i++){
    sixint(X[i].P);
    sixint(X[i].y);
    printf("\n");
  }
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct {
  int num;
  int P;
  long long int Y;
  int y;
} bigint;

int cmp( const void *p, const void *q ) {
  return ((bigint*)p)->Y - ((bigint*)q)->Y;
}

int cmp2( const void *p, const void *q ) {
    return ((bigint*)p)->num - ((bigint*)q)->num;
}

void sixint(int N){
  int i;
  int k[6];
  for(i=5;i>=0;i--){
    k[i]=N%10;
    N=(int)N/10;
  }
  for(i=0;i<6;i++){
    printf("%d",k[i]);
  }
}

int main(){
  int N,M,i;
  scanf("%d%d",&N,&M);
  bigint X[M];
  int c_P[N+1];

  for(i=0;i<M;i++){
    scanf("%d%lld",&X[i].P,&X[i].Y);
    X[i].num=i;
  }
  
  qsort(X, M, sizeof(bigint), cmp);

  for(i=0;i<N+1;i++){
    c_P[i]=1;
  }

  for(i=0;i<M;i++){
    X[i].y = c_P[X[i].P];
    c_P[X[i].P]=c_P[X[i].P]+1;
  }
  
  qsort(X, M, sizeof(bigint), cmp2 );

  for(i=0;i<M;i++){
    sixint(X[i].P);
    sixint(X[i].y);
    printf("\n");
  }
  return 0;
}
//  [javascript]
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9 + 7;

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var p = o.m(m);
  var q = p.concat();
  p.sort((a,b)=>a[1]-b[1]);
  var a = Array(n+1).fill(1);
  var y = {};
  for(var i = 0; i < m; i++){
    y[p[i][1]] = a[p[i][0]]++;
  }
  var ans = [];
  for(i = 0; i < m; i++){
    ans[i] = ("000000"+q[i][0]).slice(-6);
    ans[i] += ("000000"+y[q[i][1]]).slice(-6);
  }
  return ans.join("\n");
}
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  C=new Array(M);
  P=new Array(0);
  for(i=0;i<M;i++){
    tmp=input[i+1].split(" ");
    Csub=[parseInt(tmp[0]),parseInt(tmp[1]),i];
    C[i]=Csub;
  }
  C.sort(function(a, b) {
    return (a[0]-b[0]||a[1]-b[1])
	});
  for(i=0;i<M;i++){
    var y="";
    c=`00000${C[i][0]}`.slice(-6);
    if(i==0){
      var cnt=1;
    }else if(C[i][0]!=C[i-1][0]){
      cnt=1;
    }else{
      cnt++;
    }
    y=`00000${cnt}`.slice(-6);
    P.push([`${c}${y}`,C[i][2]]);
  }
  P.sort((a,b)=>a[1]-b[1]);
  var ans="";
  for(i=0;i<M;i++){
    if(i!=M-1){
      ans=ans+P[i][0]+"\n";
    }else{
      ans=ans+P[i][0];
    }
  }


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  C=new Array(M);
  P=new Array(0);
  for(i=0;i<M;i++){
    tmp=input[i+1].split(" ");
    Csub=[parseInt(tmp[0]),parseInt(tmp[1]),i];
    C[i]=Csub;
  }
  C.sort((a, b)=>(a[0]-b[0]||a[1]-b[1]));
  for(i=0;i<M;i++){
    var y="";
    c=`00000${C[i][0]}`.slice(-6);
    if(i==0){
      var cnt=1;
    }else if(C[i][0]!=C[i-1][0]){
      cnt=1;
    }else{
      cnt++;
    }
    y=`00000${cnt}`.slice(-6);
    P.push([`${c}${y}`,C[i][2]]);
  }
  P.sort((a,b)=>a[1]-b[1]);
  var ans="";
  for(i=0;i<M;i++){
    if(i!=M-1){
      ans=ans+P[i][0]+"\n";
    }else{
      ans=ans+P[i][0];
    }
  }


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	_, m := scanInt(), scanInt()
	type city struct{ i, p, y int }
	cs := make([]city, m)
	for i := range cs {
		cs[i].i = i
		cs[i].p, cs[i].y = scanInt(), scanInt()
	}
	sort.Slice(cs, func(i, j int) bool {
		if cs[i].p == cs[j].p {
			return cs[i].y < cs[j].y
		}
		return cs[i].p < cs[j].p
	})

	xs := make([]string, m)
	p, c := 0, 0
	for _, v := range cs {
		if p != v.p {
			p = v.p
			c = 0
		}
		c++
		xs[v.i] = fmt.Sprintf("%06d%06d", p, c)
	}

	wr := bufio.NewWriter(os.Stdout)
	for _, v := range xs {
		wr.WriteString(v + "\n")
	}
	wr.Flush()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	_ = scanInt()
	m := scanInt()

	ps := make(pairs, m)
	for i := 0; i < m; i++ {
		p := scanInt()
		y := scanInt()
		ps[i] = pair{p, y, i}
	}
	sort.Sort(ps)

	ps = append(ps, pair{-1, -1, -1})
	x := 1
	ans := make([]int, m)
	for i := 0; i < m; i++ {
		ans[ps[i].num] = ps[i].p*1e6 + x
		x++
		if ps[i].p != ps[i+1].p {
			x = 1
		}
	}

	for i := 0; i < m; i++ {
		fmt.Fprintf(wr, "%012d\n", ans[i])
	}
}

type pair struct {
	p, y, num int
}

type pairs []pair

func (a pairs) Len() int      { return len(a) }
func (a pairs) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a pairs) Less(i, j int) bool {
	if a[i].p == a[j].p {
		return a[i].y < a[j].y
	}
	return a[i].p < a[j].p
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Row struct {
	idx  int
	pref int
	year int
	cnt  int
}

type Rows []Row

func (r Rows) Len() int {
	return len(r)
}

func (r Rows) Less(i, j int) bool {
	return r[i].year < r[j].year
}

func (r Rows) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	m := scanInt(sc)

	rows := make([]Row, m)
	for i := 0; i < m; i++ {
		pref := scanInt(sc)
		year := scanInt(sc)
		rows[i] = Row{
			idx:  i,
			pref: pref,
			year: year,
			cnt:  0,
		}
	}

	// Sort by year.
	sort.Sort(Rows(rows))

	assocs := make([]int, m)
	prefs := make([]int, n+1)
	for i, row := range rows {
		assocs[row.idx] = i
		prefs[row.pref] += 1
		rows[i].cnt = prefs[row.pref]
	}

	out := bufio.NewWriter(os.Stdout)
	for _, i := range assocs {
		fmt.Fprintf(out, "%06d%06d\n", rows[i].pref, rows[i].cnt)
	}
	out.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}
//  [go]
package main

import "fmt"
import "sort"

type Prefecture int

type City struct {
    Prefecture Prefecture
    CityIndex int
    Year int
    ID string
}

type Cities []City

func (c Cities) Len() int {
    return len(c)
}

func (c Cities) Swap(i, j int) {
    c[i], c[j] = c[j], c[i]
}

func (c Cities) Less(i, j int) bool{
    return c[i].Year < c[j].Year
}

type ByCityIndex struct {
    Cities
}
func (b ByCityIndex) Less(i, j int) bool{
    return b.Cities[i].CityIndex < b.Cities[j].CityIndex
}

func main(){
    tmp := scanNums(2)
    _, m := tmp[0], tmp[1] //県の数と市の数
    preMap := make(map[Prefecture]Cities)
    //市の情報を取得
    for cityIndex :=0; cityIndex < m; cityIndex++{
        tmp = scanNums(2)
        p, y := Prefecture(tmp[0]), tmp[1] //県と市ができた年
        city := City{
            Prefecture: p,
            CityIndex : cityIndex,
            Year: y,
        }
        var cities Cities
        var ok bool
        if cities, ok = preMap[p]; !ok{
            cities = make(Cities, 0)
        }
        cities = append(cities, city)
        preMap[p] = cities
    }
    //県ごとに市のIDをつける
    allCities := make(Cities, 0)
    for prefecture, cities := range preMap {
        sort.Sort(cities)
        for idx, c := range cities{
            c.ID = fmt.Sprintf("%06d", prefecture) + fmt.Sprintf("%06d", (idx+1))
            allCities = append(allCities, c)
        }
    }

    //表示するため市のindexで並び替える
    sort.Sort(ByCityIndex{allCities})
    for i:=0; i<len(allCities); i++{
        fmt.Printf("%s\n", allCities[i].ID)
    }
}


/**
 * １行に空白区切りで数字を読み込み
 */
func scanNums(len int) (nums []int) {
	nums = make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&nums[i])
	}
	return
}
//  [go]
// 「市が一つも属さない県がある場合」を忘れていて1WA

package main
import (
	"fmt"
	"sort"
)

type D struct{
	id, pref, year int
	order string
}
func main(){
	var N, M int
	fmt.Scan(&N, &M)
	Datas := make([]D, M)
	for i:=0; i<M;i++{
		var p, y int
		fmt.Scan(&p, &y)
		Datas[i] = D{id: i, pref: p, year: y, order: "init"}
	}
	sort.Slice(Datas, func(i, j int)bool{
		if Datas[i].pref < Datas[j].pref{
			return true
		}else if Datas[i].pref > Datas[j].pref{
			return false
		}else{
			return Datas[i].year < Datas[j].year
		}
	})
	p := 1	// これは危険で、「県1は存在する」と決め打っているのでダメ
	idx := 1
	ans := make([]string, M)
	// なぜか構造体のスライスのプロパティを変えることができなかったので答え出力用の配列をつくったけどなんで？？？？？
	for i:=0; i<M; i++{
		d := Datas[i]
		if p != d.pref{
			p = d.pref
			idx=1
		}
			// ほんとはこれだけでorderがセットされてほしいんだけどなんかできない（空になってしまう
		d.order = fmt.Sprintf("%06d", p) + fmt.Sprintf("%06d", idx)
		ans[d.id] = d.order
		idx++
	}
	for _, a := range ans{
		fmt.Println(a)
	}
}
//  [ruby]
n, m = gets.split.map(&:to_i)
prefs = Array.new(n+1).map{{}}
codes = Array.new(m)
m.times do |i|
  p, y = gets.split.map(&:to_i)
  prefs[p][i] = y
end
prefs.each_with_index do |pref, pref_no|
  city_no = 1
  pref.sort{|a,b| a[1]<=>b[1]}.each do |i, y|
    codes[i] = sprintf("%06d%06d", pref_no, city_no)
    city_no += 1
  end
end

codes.each{puts _1}
//  [ruby]
n, m = gets.split(' ').map(&:to_i)
cities = m.times.map {|i| gets.split(' ').map(&:to_i) }
grouped = cities.group_by {|city| city[0] }
grouped.each do |pref, cs|
  cs.sort! {|a, b| a[1] <=> b[1] }.each.with_index do |c, i|
    c << i + 1
  end
end

cities.each do |c|
  puts "%06d%06d" % [c[0], c[2]]
end
//  [ruby]
n,m = gets.strip.split.map(&:to_i)
pref = Array.new(n){Array.new}
i = 1
while i <= m do
  p,y = gets.strip.split.map(&:to_i)
  pref[p-1] << [i,y].to_a  #[市の番号,誕生年]
  i += 1
end
#すべて入力完了
#全ての配列を年代順にソート
city = Array.new(m)
j = 0
while j < n do
  unless pref[j] == nil
    pref[j].sort! {|a, b| a[1] <=> b[1] }
    k = 0
    while k < pref[j].size do
      city[pref[j][k][0]-1] = ('%012d' % ((j+1)*(10**6)+(k+1)))
      k += 1
    end
  end
  j += 1
end
m.times do |d|
  puts city[d]
end
//  [ruby]
require "pp"

N, M = gets.split.map(&:to_i)
city_array = []
M.times{|index|
  nums = gets.split.map(&:to_i)
  city_array << {index: index, prefec: nums[0], year: nums[1]}
}

sorted_array = city_array.sort{|a, b|
  a[:year] <=> b[:year]
}

backet_hash = {}

city_id_array = sorted_array.map{|item|
  index = backet_hash[item[:prefec].to_s.to_sym]
  index ||= 1
  p_id = format("%06d", item[:prefec]).to_s
  city_id = format("%06d", index).to_s
  index += 1
  backet_hash[item[:prefec].to_s.to_sym] = index

  {index: item[:index], id: (p_id + city_id).to_i}
}

city_id_array.sort{|a, b|
  a[:index] <=> b[:index]
}.each{|item|
  puts format("%012d", item[:id])
}