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

A = [[i,list(map(int,input().split()))] for i in range(m)]

B = []

i = 0

x = 0

for a in sorted(A,key=lambda l:(l[1][0],l[1][1])):

    if i==a[1][0]:

        x += 1

        B.append([a[0],str(a[1][0]).zfill(6)+str(x).zfill(6)])

    else:

        x = 1

        B.append([a[0],str(a[1][0]).zfill(6)+str(x).zfill(6)])

        i = a[1][0]

for b in sorted(B):

    print((b[1]))
n, m = list(map(int, input().split()))

A = []

B = [''] * m

for i in range(m):

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

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

A.sort()

count = 0

i, x = 1, 1

for a in A:

    if a[0] == i:

        B[a[2]] = '{:06}{:06}'.format(a[0], x)

    else:

        i, x = a[0], 1

        B[a[2]] = '{:06}{:06}'.format(a[0], x)

    x += 1

for b in B:

    print(b)
n, m = list(map(int, input().split()))
A = [[i, list(map(int, input().split()))] for i in range(m)]
B = []
i = 0
x = 0
for a in sorted(A, key=lambda l: (l[1][0], l[1][1])):
    if i == a[1][0]:
        x += 1
        B.append([a[0], str(a[1][0]).zfill(6) + str(x).zfill(6)])
    else:
        x = 1
        B.append([a[0], str(a[1][0]).zfill(6) + str(x).zfill(6)])
        i = a[1][0]
for b in sorted(B):
    print((b[1]))

n, m = list(map(int, input().split()))
A = []
B = [""] * m
for i in range(m):
    p, y = list(map(int, input().split()))
    A.append([p, y, i])
A.sort()
count = 0
i, x = 1, 1
for a in A:
    if a[0] == i:
        B[a[2]] = "{:06}{:06}".format(a[0], x)
    else:
        i, x = a[0], 1
        B[a[2]] = "{:06}{:06}".format(a[0], x)
    x += 1
for b in B:
    print(b)

-A = [[i, list(map(int, input().split()))] for i in range(m)] -B = [] -i = 0 -x = 0 -for a in sorted(A, key=lambda l: (l[1][0], l[1][1])): -    if i == a[1][0]: -        x += 1 -        B.append([a[0], str(a[1][0]).zfill(6) + str(x).zfill(6)]) +A = [] +B = [""] * m +for i in range(m): +    p, y = list(map(int, input().split())) +    A.append([p, y, i]) +A.sort() +count = 0 +i, x = 1, 1 +for a in A: +    if a[0] == i: +        B[a[2]] = "{:06}{:06}".format(a[0], x) -        x = 1 -        B.append([a[0], str(a[1][0]).zfill(6) + str(x).zfill(6)]) -        i = a[1][0] -for b in sorted(B): -    print((b[1])) +        i, x = a[0], 1 +        B[a[2]] = "{:06}{:06}".format(a[0], x) +    x += 1 +for b in B: +    print(b)