from collections import defaultdict

dd = defaultdict(str)



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

keys = []

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

for i in range(m):

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

    key_p = str(p).zfill(6)

    key_y = str(y).zfill(10)

    keys.append(key_p + key_y)

    p -= 1

    atcoder[p].append(y)

for i in range(n):

    atcoder[i].sort()

    key_i = str(i + 1).zfill(6)

    for index, j in enumerate(atcoder[i]):

        key_index = str(index + 1).zfill(6)

        key_j = str(j).zfill(10)

        dd[key_i + key_j] = key_i + key_index

for k in keys:

    print((dd[k]))
def main():

    from collections import defaultdict

    dd = defaultdict(str)



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

    keys = []

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

    for i in range(m):

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

        key_p = str(p).zfill(6)

        key_y = str(y).zfill(10)

        keys.append(key_p + key_y)

        p -= 1

        atcoder[p].append(y)

    for i in range(n):

        atcoder[i].sort()

        key_i = str(i + 1).zfill(6)

        for index, j in enumerate(atcoder[i]):

            key_index = str(index + 1).zfill(6)

            key_j = str(j).zfill(10)

            dd[key_i + key_j] = key_i + key_index

    for k in keys:

        print((dd[k]))





if __name__ == "__main__":

    main()
from collections import defaultdict

dd = defaultdict(str)
n, m = list(map(int, input().split()))
keys = []
atcoder = [[] for _ in range(n)]
for i in range(m):
    p, y = list(map(int, input().split()))
    key_p = str(p).zfill(6)
    key_y = str(y).zfill(10)
    keys.append(key_p + key_y)
    p -= 1
    atcoder[p].append(y)
for i in range(n):
    atcoder[i].sort()
    key_i = str(i + 1).zfill(6)
    for index, j in enumerate(atcoder[i]):
        key_index = str(index + 1).zfill(6)
        key_j = str(j).zfill(10)
        dd[key_i + key_j] = key_i + key_index
for k in keys:
    print((dd[k]))

def main():
    from collections import defaultdict

    dd = defaultdict(str)
    n, m = list(map(int, input().split()))
    keys = []
    atcoder = [[] for _ in range(n)]
    for i in range(m):
        p, y = list(map(int, input().split()))
        key_p = str(p).zfill(6)
        key_y = str(y).zfill(10)
        keys.append(key_p + key_y)
        p -= 1
        atcoder[p].append(y)
    for i in range(n):
        atcoder[i].sort()
        key_i = str(i + 1).zfill(6)
        for index, j in enumerate(atcoder[i]):
            key_index = str(index + 1).zfill(6)
            key_j = str(j).zfill(10)
            dd[key_i + key_j] = key_i + key_index
    for k in keys:
        print((dd[k]))


if __name__ == "__main__":
    main()

-from collections import defaultdict +def main(): +    from collections import defaultdict -dd = defaultdict(str) -n, m = list(map(int, input().split())) -keys = [] -atcoder = [[] for _ in range(n)] -for i in range(m): -    p, y = list(map(int, input().split())) -    key_p = str(p).zfill(6) -    key_y = str(y).zfill(10) -    keys.append(key_p + key_y) -    p -= 1 -    atcoder[p].append(y) -for i in range(n): -    atcoder[i].sort() -    key_i = str(i + 1).zfill(6) -    for index, j in enumerate(atcoder[i]): -        key_index = str(index + 1).zfill(6) -        key_j = str(j).zfill(10) -        dd[key_i + key_j] = key_i + key_index -for k in keys: -    print((dd[k])) +    dd = defaultdict(str) +    n, m = list(map(int, input().split())) +    keys = [] +    atcoder = [[] for _ in range(n)] +    for i in range(m): +        p, y = list(map(int, input().split())) +        key_p = str(p).zfill(6) +        key_y = str(y).zfill(10) +        keys.append(key_p + key_y) +        p -= 1 +        atcoder[p].append(y) +    for i in range(n): +        atcoder[i].sort() +        key_i = str(i + 1).zfill(6) +        for index, j in enumerate(atcoder[i]): +            key_index = str(index + 1).zfill(6) +            key_j = str(j).zfill(10) +            dd[key_i + key_j] = key_i + key_index +    for k in keys: +        print((dd[k])) + + +if __name__ == "__main__": +    main()