100 atcoder#ABC113C. [ABC113C] ID

[ABC113C] ID

Score: 300300 points

Problem Statement

In Republic of Atcoder, there are NN prefectures, and a total of MM cities that belong to those prefectures.

City ii is established in year YiY_i and belongs to Prefecture PiP_i.

You can assume that there are no multiple cities that are established in the same year.

It is decided to allocate a 1212-digit ID number to each city.

If City ii is the xx-th established city among the cities that belong to Prefecture ii, the first six digits of the ID number of City ii is PiP_i, and the last six digits of the ID number is xx.

Here, if PiP_i or xx (or both) has less than six digits, zeros are added to the left until it has six digits.

Find the ID numbers for all the cities.

Note that there can be a prefecture with no cities.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1M1051 \leq M \leq 10^5
  • 1PiN1 \leq P_i \leq N
  • 1Yi1091 \leq Y_i \leq 10^9
  • YiY_i are all different.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

P1P_1 Y1Y_1

::

PMP_M YMY_M

Output

Print the ID numbers for all the cities, in ascending order of indices (City 11, City 22, ......).

2 3
1 32
2 63
1 12
000001000002
000002000001
000001000001
  • As City 11 is the second established city among the cities that belong to Prefecture 11, its ID number is 000001000002000001000002.
  • As City 22 is the first established city among the cities that belong to Prefecture 22, its ID number is 000002000001000002000001.
  • As City 33 is the first established city among the cities that belong to Prefecture 11, its ID number is 000001000001000001000001.
2 3
2 55
2 77
2 99
000002000001
000002000002
000002000003