PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000006. Cấp mã cho các thành phố (ID)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cấp mã cho các thành phố (ID)

ID

Source: AtCoder Version: Phuoc Hung OJ Extended

Problem Statement

A country has NN prefectures and MM cities. City ii belongs to prefecture PiP_i and was founded in year YiY_i. Its 12-digit ID contains the 6-digit prefecture number followed by its 6-digit founding order within that prefecture, starting at 11. Pad either part with leading zeros. All founding years are distinct. Print the IDs in original input order.

Input

The first line contains NN and MM. Each of the next MM lines contains PiP_i and YiY_i for city ii.

Output

Print MM lines, giving each city’s exactly 12-digit identifier in input order.

Subtasks

  • Subtask 1 (20 points): 1≤N,M≤251\le N,M\le 25; 1≤Pi≤N1\le P_i\le N; 1≤Yi≤1091\le Y_i\le 10^9; all YiY_i are distinct.
  • Subtask 2 (30 points): 1≤N,M≤25001\le N,M\le 2500; 1≤Pi≤N1\le P_i\le N; 1≤Yi≤1091\le Y_i\le 10^9; all YiY_i are distinct.
  • Subtask 3 (50 points): 1≤N,M≤1051\le N,M\le 10^5; 1≤Pi≤N1\le P_i\le N; 1≤Yi≤1091\le Y_i\le 10^9; all YiY_i are distinct.

Examples

Input

2 4
1 2000
2 1999
1 1990
1 2010

Output

000001000002
000002000001
000001000001
000001000003

Explanation

Within prefecture 11, the years are 1990,2000,20101990,2000,2010. The first input city is second, giving 000001000002.