Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
PY = []
array1 = []
array2 = []

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    if P in array1:
        array2[array1.index(P)].append(Y)
    else:
        array1.append(P)
        array2.append([Y])
        
for i in range(len(array2)):
    array2[i].sort()

for i in PY:
    print('{:06}'.format(i[0]), end='')
    print('{:06}'.format(array2[array1.index(i[0])].index(i[1])+1))

Fixed submission:
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)

for p, y in PY:
    n = bisect.bisect_left(sorted(array[p-1]), y) + 1
    print('%06d%06d' % (p, n))


Fixed submission:
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)

for p, y in PY:
    print('%06d%06d' % (p, sorted(array[p-1]).index(y)+1))


Fixed submission:
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
PY = []
array1 = []
array2 = []

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    if P in array1:
        array2[array1.index(P)].append(Y)
    else:
        array1.append(P)
        array2.append([Y])

for i in PY:
    print('{:06}'.format(i[0]), end='')
    print('{:06}'.format(sorted(array2[array1.index(i[0])]).index(i[1])+1))


Fixed submission:
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
PY = []
array1 = []
array2 = []

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    if P in array1:
        array2[array1.index(P)].append(Y)
    else:
        array1.append(P)
        array2.append([Y])

for i in PY:
    print('{:06}'.format(i[0]), end='')
    print('{:06}'.format(sorted(array2[array1.index(i[0])]).index(i[1])+1))


Fixed submission:
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)

for i in PY:
    print('{:06}'.format(i[0]), end='')
    print('{:06}'.format(sorted(array[i[0]-1]).index(i[1])+1))


Fixed submission:
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]
A = list(PY)
A = sorted(A, key=lambda x: x[1])

for i in PY:
    B = []
    for j in A:
        if j[0] == i[0]:
            B.append(j[1])
            
    print('{:06}'.format(i[0]), end='')
    print('{:06}'.format(B.index(i[1])+1))


Fixed submission:
import bisect

N, M = map(int, input().split())
PY = []
array = [[] for _ in range(N)]

for _ in range(M):
    P, Y = map(int, input().split())
    PY.append([P, Y])
    array[P-1].append(Y)
    
for i in range(N):
    array[i].sort()

for p, y in PY:
    n = bisect.bisect_left(array[p-1], y) + 1
    print('%06d%06d' % (p, n))