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

X = [[i] + list(map(int, input().split())) for i in range(M)]

X.sort(key=lambda x: (x[1], x[2]))



city = X[0][1]

num = 0

for v in X:

    if city == v[1]:

        num += 1

    else:

        city = v[1]

        num = 1

    v.append(num)



X.sort()

for v in X:

    print(('{:06}{:06}'.format(v[1], v[3])))

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

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

ans = [''] * M

num = [1] * N



for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):

    ans[i] = '{:06}{:06}'.format(v[0], num[v[0] - 1])

    num[v[0] - 1] += 1

    

print(('\n'.join(ans)))
N, M = list(map(int, input().split()))
X = [[i] + list(map(int, input().split())) for i in range(M)]
X.sort(key=lambda x: (x[1], x[2]))
city = X[0][1]
num = 0
for v in X:
    if city == v[1]:
        num += 1
    else:
        city = v[1]
        num = 1
    v.append(num)
X.sort()
for v in X:
    print(("{:06}{:06}".format(v[1], v[3])))

N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
ans = [""] * M
num = [1] * N
for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
    ans[i] = "{:06}{:06}".format(v[0], num[v[0] - 1])
    num[v[0] - 1] += 1
print(("\n".join(ans)))

-X = [[i] + list(map(int, input().split())) for i in range(M)] -X.sort(key=lambda x: (x[1], x[2])) -city = X[0][1] -num = 0 -for v in X: -    if city == v[1]: -        num += 1 -    else: -        city = v[1] -        num = 1 -    v.append(num) -X.sort() -for v in X: -    print(("{:06}{:06}".format(v[1], v[3]))) +X = [list(map(int, input().split())) for _ in range(M)] +ans = [""] * M +num = [1] * N +for i, v in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])): +    ans[i] = "{:06}{:06}".format(v[0], num[v[0] - 1]) +    num[v[0] - 1] += 1 +print(("\n".join(ans)))