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

py = []

for i in range(m):

    py.append(list(map(int,input().split())))

    py[i].append(i)

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

py.sort(key=lambda x:x[0])

x = py[0][0]

j=0

for i in range(m):

    if x != py[i][0]:

        j = 1

        x = py[i][0]

    else:

        j+=1

    s = str(py[i][0]).zfill(6) + str(j).zfill(6)

    py[i].append(s)

py.sort(key=lambda x:x[2])

for i in range(m):

    print((py[i][3]))
n,m=list(map(int,input().split()))

e=[[]for _ in range(n)]

py=[]

for _ in range(m):

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

  py.append((p,y))

  e[p-1].append(y)

for i in range(n):e[i].sort()

xy=lambda x,y:y*1000000+x

d={}

for i in range(n):

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

    d[xy(i+1,e[i][j])]=str(i+1).zfill(6)+str(j+1).zfill(6)

for p,y in py:

  print((d[xy(p,y)]))

n, m = list(map(int, input().split()))
py = []
for i in range(m):
    py.append(list(map(int, input().split())))
    py[i].append(i)
py.sort(key=lambda x: x[1])
py.sort(key=lambda x: x[0])
x = py[0][0]
j = 0
for i in range(m):
    if x != py[i][0]:
        j = 1
        x = py[i][0]
    else:
        j += 1
    s = str(py[i][0]).zfill(6) + str(j).zfill(6)
    py[i].append(s)
py.sort(key=lambda x: x[2])
for i in range(m):
    print((py[i][3]))

n, m = list(map(int, input().split()))
e = [[] for _ in range(n)]
py = []
for _ in range(m):
    p, y = list(map(int, input().split()))
    py.append((p, y))
    e[p - 1].append(y)
for i in range(n):
    e[i].sort()
xy = lambda x, y: y * 1000000 + x
d = {}
for i in range(n):
    for j in range(len(e[i])):
        d[xy(i + 1, e[i][j])] = str(i + 1).zfill(6) + str(j + 1).zfill(6)
for p, y in py:
    print((d[xy(p, y)]))

+e = [[] for _ in range(n)] -for i in range(m): -    py.append(list(map(int, input().split()))) -    py[i].append(i) -py.sort(key=lambda x: x[1]) -py.sort(key=lambda x: x[0]) -x = py[0][0] -j = 0 -for i in range(m): -    if x != py[i][0]: -        j = 1 -        x = py[i][0] -    else: -        j += 1 -    s = str(py[i][0]).zfill(6) + str(j).zfill(6) -    py[i].append(s) -py.sort(key=lambda x: x[2]) -for i in range(m): -    print((py[i][3])) +for _ in range(m): +    p, y = list(map(int, input().split())) +    py.append((p, y)) +    e[p - 1].append(y) +for i in range(n): +    e[i].sort() +xy = lambda x, y: y * 1000000 + x +d = {} +for i in range(n): +    for j in range(len(e[i])): +        d[xy(i + 1, e[i][j])] = str(i + 1).zfill(6) + str(j + 1).zfill(6) +for p, y in py: +    print((d[xy(p, y)]))