import numpy as np

N, M = list(map(int, input().split()))

data = np.zeros((4, M))

 

for i in range(M):

    data[0, i] = i+1

    data[1:3, i] = list(map(int, input().split()))

 

city = [0 for i in range(N)]

data = data[:, np.argsort(data[2, :])]

for i in range(M):

    city[int(data[1, i]-1)] += 1

    data[3, i] = city[int(data[1, i]-1)]

 

data = data[:, np.argsort(data[0, :])]

for i in range(M):

    tmp = str(int(data[1, i])).zfill(6) + str(int(data[3, i])).zfill(6)

    print(tmp)
N,M=list(map(int,input().split()))

city=[]

for i in range(M):

    p,y=list(map(int,input().split()))

    city.append([i,p,y])



city.sort(key = lambda t:t[2])

city.sort(key = lambda t:t[1])



id=1

old_city=0

for city_id in city:

    if city_id[1]!=old_city:

        id=1

    city_id[2]=id

    id+=1

    old_city=city_id[1]



city.sort(key = lambda t:t[0])



for x in city:

    ans=x[1]*1000000+x[2]

    print(("{0:012d}".format(ans)))

import numpy as np

N, M = list(map(int, input().split()))
data = np.zeros((4, M))
for i in range(M):
    data[0, i] = i + 1
    data[1:3, i] = list(map(int, input().split()))
city = [0 for i in range(N)]
data = data[:, np.argsort(data[2, :])]
for i in range(M):
    city[int(data[1, i] - 1)] += 1
    data[3, i] = city[int(data[1, i] - 1)]
data = data[:, np.argsort(data[0, :])]
for i in range(M):
    tmp = str(int(data[1, i])).zfill(6) + str(int(data[3, i])).zfill(6)
    print(tmp)

N, M = list(map(int, input().split()))
city = []
for i in range(M):
    p, y = list(map(int, input().split()))
    city.append([i, p, y])
city.sort(key=lambda t: t[2])
city.sort(key=lambda t: t[1])
id = 1
old_city = 0
for city_id in city:
    if city_id[1] != old_city:
        id = 1
    city_id[2] = id
    id += 1
    old_city = city_id[1]
city.sort(key=lambda t: t[0])
for x in city:
    ans = x[1] * 1000000 + x[2]
    print(("{0:012d}".format(ans)))

-import numpy as np - -data = np.zeros((4, M)) +city = [] -    data[0, i] = i + 1 -    data[1:3, i] = list(map(int, input().split())) -city = [0 for i in range(N)] -data = data[:, np.argsort(data[2, :])] -for i in range(M): -    city[int(data[1, i] - 1)] += 1 -    data[3, i] = city[int(data[1, i] - 1)] -data = data[:, np.argsort(data[0, :])] -for i in range(M): -    tmp = str(int(data[1, i])).zfill(6) + str(int(data[3, i])).zfill(6) -    print(tmp) +    p, y = list(map(int, input().split())) +    city.append([i, p, y]) +city.sort(key=lambda t: t[2]) +city.sort(key=lambda t: t[1]) +id = 1 +old_city = 0 +for city_id in city: +    if city_id[1] != old_city: +        id = 1 +    city_id[2] = id +    id += 1 +    old_city = city_id[1] +city.sort(key=lambda t: t[0]) +for x in city: +    ans = x[1] * 1000000 + x[2] +    print(("{0:012d}".format(ans)))