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

from bisect import bisect_right

dic = [[] for i in range(N)]



shi = {}

for i in range(M):

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

    dic[p-1].append(y)

    shi[i] = (p, y)



for i in range(N):

    dic[i].sort()



for j in range(M):

    p, y = shi[j]

    print(('{:06}{:06}'.format(p, bisect_right(dic[p-1], y))))



import sys

def input(): return sys.stdin.readline().strip()

def mapint(): return list(map(int, input().split()))

sys.setrecursionlimit(10**9)



N, M = mapint()

lis = [[] for _ in range(N)]



plis = []

for _ in range(M):

    p, y = mapint()

    lis[p-1].append(y)

    plis.append((p, y))



for i in range(N):

    lis[i].sort()

    

from bisect import bisect_left

for p, y in plis:

    idx = bisect_left(lis[p-1], y)

    print(('{:06}{:06}'.format(p, idx+1)))
N, M = list(map(int, input().split()))
from bisect import bisect_right

dic = [[] for i in range(N)]
shi = {}
for i in range(M):
    p, y = list(map(int, input().split()))
    dic[p - 1].append(y)
    shi[i] = (p, y)
for i in range(N):
    dic[i].sort()
for j in range(M):
    p, y = shi[j]
    print(("{:06}{:06}".format(p, bisect_right(dic[p - 1], y))))

import sys


def input():
    return sys.stdin.readline().strip()


def mapint():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)
N, M = mapint()
lis = [[] for _ in range(N)]
plis = []
for _ in range(M):
    p, y = mapint()
    lis[p - 1].append(y)
    plis.append((p, y))
for i in range(N):
    lis[i].sort()
from bisect import bisect_left

for p, y in plis:
    idx = bisect_left(lis[p - 1], y)
    print(("{:06}{:06}".format(p, idx + 1)))

-N, M = list(map(int, input().split())) -from bisect import bisect_right +import sys -dic = [[] for i in range(N)] -shi = {} -for i in range(M): -    p, y = list(map(int, input().split())) -    dic[p - 1].append(y) -    shi[i] = (p, y) + +def input(): +    return sys.stdin.readline().strip() + + +def mapint(): +    return list(map(int, input().split())) + + +sys.setrecursionlimit(10**9) +N, M = mapint() +lis = [[] for _ in range(N)] +plis = [] +for _ in range(M): +    p, y = mapint() +    lis[p - 1].append(y) +    plis.append((p, y)) -    dic[i].sort() -for j in range(M): -    p, y = shi[j] -    print(("{:06}{:06}".format(p, bisect_right(dic[p - 1], y)))) +    lis[i].sort() +from bisect import bisect_left + +for p, y in plis: +    idx = bisect_left(lis[p - 1], y) +    print(("{:06}{:06}".format(p, idx + 1)))