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

cnt = [0 for i in range(N + 1)] 

check = []

ans = []



for i in range(M):

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

    check.append((y, p, i))



check.sort()



for y, p, i in check:

    cnt[p] += 1

    ans.append((i,str(p).zfill(6)+str(cnt[p]).zfill(6)))



ans.sort()



for aa, bb in ans:

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

data = [[] for i in range(M)]

ans = [""] * M

num = [0] * N

for i in range(M):

    ken, year = list(map(int, input().split()))

    data[i] = [ken, year, i]

    

data.sort(key=lambda x:x[1])



for p, y, i in data:

    num[p-1] += 1

    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)



for i in ans:

    print(i)
N, M = list(map(int, input().split()))
cnt = [0 for i in range(N + 1)]
check = []
ans = []
for i in range(M):
    p, y = list(map(int, input().split()))
    check.append((y, p, i))
check.sort()
for y, p, i in check:
    cnt[p] += 1
    ans.append((i, str(p).zfill(6) + str(cnt[p]).zfill(6)))
ans.sort()
for aa, bb in ans:
    print(bb)

N, M = list(map(int, input().split()))
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * N
for i in range(M):
    ken, year = list(map(int, input().split()))
    data[i] = [ken, year, i]
data.sort(key=lambda x: x[1])
for p, y, i in data:
    num[p - 1] += 1
    ans[i] = str(p).zfill(6) + str(num[p - 1]).zfill(6)
for i in ans:
    print(i)

-cnt = [0 for i in range(N + 1)] -check = [] -ans = [] +data = [[] for i in range(M)] +ans = [""] * M +num = [0] * N -    p, y = list(map(int, input().split())) -    check.append((y, p, i)) -check.sort() -for y, p, i in check: -    cnt[p] += 1 -    ans.append((i, str(p).zfill(6) + str(cnt[p]).zfill(6))) -ans.sort() -for aa, bb in ans: -    print(bb) +    ken, year = list(map(int, input().split())) +    data[i] = [ken, year, i] +data.sort(key=lambda x: x[1]) +for p, y, i in data: +    num[p - 1] += 1 +    ans[i] = str(p).zfill(6) + str(num[p - 1]).zfill(6) +for i in ans: +    print(i)