n,m=list(map(int,input().split()))

l=[{} for k in range(n)]

for i in range(m):

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

    l[p-1][y]=i

for k in range(n):

    l[k]=sorted(list(l[k].items()), key=lambda x:x[0])

s=[0]*m

for k in range(n):

    for r, p in enumerate(l[k]):

        s[p[1]]=[k,r]

for i in s:

    print(('{:06}{:06}'.format(i[0]+1,i[1]+1)))
n,m=list(map(int,input().split()))

l=[[] for i in range(n)]

for i in range(m):

    p,y=input().split()

    l[int(p)-1].append(y.zfill(10)+str(i).zfill(6))

for i in range(n):

    l[i].sort()

s=[0]*m

for i in range(n):

    for j in range(len(l[i])):

        s[int(l[i][j][10:16])]=str(i+1).zfill(6)+str(j+1).zfill(6)

for i in s:

    print(i)

n, m = list(map(int, input().split()))
l = [{} for k in range(n)]
for i in range(m):
    p, y = list(map(int, input().split()))
    l[p - 1][y] = i
for k in range(n):
    l[k] = sorted(list(l[k].items()), key=lambda x: x[0])
s = [0] * m
for k in range(n):
    for r, p in enumerate(l[k]):
        s[p[1]] = [k, r]
for i in s:
    print(("{:06}{:06}".format(i[0] + 1, i[1] + 1)))

n, m = list(map(int, input().split()))
l = [[] for i in range(n)]
for i in range(m):
    p, y = input().split()
    l[int(p) - 1].append(y.zfill(10) + str(i).zfill(6))
for i in range(n):
    l[i].sort()
s = [0] * m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][10:16])] = str(i + 1).zfill(6) + str(j + 1).zfill(6)
for i in s:
    print(i)

-l = [{} for k in range(n)] +l = [[] for i in range(n)] -    p, y = list(map(int, input().split())) -    l[p - 1][y] = i -for k in range(n): -    l[k] = sorted(list(l[k].items()), key=lambda x: x[0]) +    p, y = input().split() +    l[int(p) - 1].append(y.zfill(10) + str(i).zfill(6)) +for i in range(n): +    l[i].sort() -for k in range(n): -    for r, p in enumerate(l[k]): -        s[p[1]] = [k, r] +for i in range(n): +    for j in range(len(l[i])): +        s[int(l[i][j][10:16])] = str(i + 1).zfill(6) + str(j + 1).zfill(6) -    print(("{:06}{:06}".format(i[0] + 1, i[1] + 1))) +    print(i)