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

digit = 'zero padding: {:0=6}'

dic = [[] for _ in range(N+1)]



for i in range(M):

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

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



for p in dic:

    p.sort()



ans = [None for _ in range(M)]

for k in range(1,N+1):

    p = dic[k]

    for j in range(len(p)):

        i = p[j][1]

        ID = str(k).zfill(6)+str(j+1).zfill(6)

        ans[i] = ID



for a in ans:

    print(a)

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

PY = [list(map(int,input().split())) for _ in range(M)]



dic = [[] for _ in range(N+1)]

for p,y in PY:

    dic[p].append(y)



for a in dic:

    a.sort()



dic2 = [{} for _ in range(N+1)]

for p in range(N+1):

    dic2[p] = {y:i+1 for i,y in enumerate(dic[p])}



for p,y in PY:

    y = dic2[p][y]

    print((str(p).zfill(6)+str(y).zfill(6)))

N, M = list(map(int, input().split()))
digit = "zero padding: {:0=6}"
dic = [[] for _ in range(N + 1)]
for i in range(M):
    p, y = list(map(int, input().split()))
    dic[p].append((y, i))
for p in dic:
    p.sort()
ans = [None for _ in range(M)]
for k in range(1, N + 1):
    p = dic[k]
    for j in range(len(p)):
        i = p[j][1]
        ID = str(k).zfill(6) + str(j + 1).zfill(6)
        ans[i] = ID
for a in ans:
    print(a)

N, M = list(map(int, input().split()))
PY = [list(map(int, input().split())) for _ in range(M)]
dic = [[] for _ in range(N + 1)]
for p, y in PY:
    dic[p].append(y)
for a in dic:
    a.sort()
dic2 = [{} for _ in range(N + 1)]
for p in range(N + 1):
    dic2[p] = {y: i + 1 for i, y in enumerate(dic[p])}
for p, y in PY:
    y = dic2[p][y]
    print((str(p).zfill(6) + str(y).zfill(6)))

-digit = "zero padding: {:0=6}" +PY = [list(map(int, input().split())) for _ in range(M)] -for i in range(M): -    p, y = list(map(int, input().split())) -    dic[p].append((y, i)) -for p in dic: -    p.sort() -ans = [None for _ in range(M)] -for k in range(1, N + 1): -    p = dic[k] -    for j in range(len(p)): -        i = p[j][1] -        ID = str(k).zfill(6) + str(j + 1).zfill(6) -        ans[i] = ID -for a in ans: -    print(a) +for p, y in PY: +    dic[p].append(y) +for a in dic: +    a.sort() +dic2 = [{} for _ in range(N + 1)] +for p in range(N + 1): +    dic2[p] = {y: i + 1 for i, y in enumerate(dic[p])} +for p, y in PY: +    y = dic2[p][y] +    print((str(p).zfill(6) + str(y).zfill(6)))