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

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



for k in range(M):

    L[k].append(k)

L = sorted(L)



A = [[L[0][0],1,L[0][2]]]

t = 1



for k in range(1,M):

    if L[k-1][0] != L[k][0]:

        t = 1

    else:

        t += 1

    A.append([L[k][0],t,L[k][2]])



A = sorted(A, key = lambda x: x[2])



for a in A:

    print((str(a[0]).zfill(6) + str(a[1]).zfill(6)))
N, M = list(map(int,input().split()))

P = [[] for k in range(N)]

A = [0 for k in range(M)]



for k in range(M):

    s, t = list(map(int,input().split()))

    P[s-1].append([t,k])



for k in range(N):

    P[k].sort()

    for l in range(len(P[k])):

        A[P[k][l][1]] = str(k+1).zfill(6) + str(l+1).zfill(6)



for a in A:

    print(("".join(a)))
N, M = list(map(int, input().split()))
L = [list(map(int, input().split())) for k in range(M)]
for k in range(M):
    L[k].append(k)
L = sorted(L)
A = [[L[0][0], 1, L[0][2]]]
t = 1
for k in range(1, M):
    if L[k - 1][0] != L[k][0]:
        t = 1
    else:
        t += 1
    A.append([L[k][0], t, L[k][2]])
A = sorted(A, key=lambda x: x[2])
for a in A:
    print((str(a[0]).zfill(6) + str(a[1]).zfill(6)))

N, M = list(map(int, input().split()))
P = [[] for k in range(N)]
A = [0 for k in range(M)]
for k in range(M):
    s, t = list(map(int, input().split()))
    P[s - 1].append([t, k])
for k in range(N):
    P[k].sort()
    for l in range(len(P[k])):
        A[P[k][l][1]] = str(k + 1).zfill(6) + str(l + 1).zfill(6)
for a in A:
    print(("".join(a)))

-L = [list(map(int, input().split())) for k in range(M)] +P = [[] for k in range(N)] +A = [0 for k in range(M)] -    L[k].append(k) -L = sorted(L) -A = [[L[0][0], 1, L[0][2]]] -t = 1 -for k in range(1, M): -    if L[k - 1][0] != L[k][0]: -        t = 1 -    else: -        t += 1 -    A.append([L[k][0], t, L[k][2]]) -A = sorted(A, key=lambda x: x[2]) +    s, t = list(map(int, input().split())) +    P[s - 1].append([t, k]) +for k in range(N): +    P[k].sort() +    for l in range(len(P[k])): +        A[P[k][l][1]] = str(k + 1).zfill(6) + str(l + 1).zfill(6) -    print((str(a[0]).zfill(6) + str(a[1]).zfill(6))) +    print(("".join(a)))