Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
n, m = map(int, input().split())
py = []
dict_p = {}
for i in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
    if p not in dict_p.keys():
        dict_p[p] = list()

    dict_p[p].append(y)
#print(dict_p)
for values in dict_p.values():
    values.sort()

for p, y in py:
    x = bisect_left(dict_p[p], y)
    ans = "{:006}".format(p) + "{:006}".format(x+1)
    print(ans)


Fixed submission:
from bisect import bisect_left
from collections import defaultdict
n, m = map(int, input().split())
py = []
dict_p = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
    dict_p[p].append(y)
#print(dict_p)
for values in dict_p.values():
    values.sort()

for p, y in py:
    x = bisect_left(dict_p[p], y)
    ans = "{:006}".format(p) + "{:006}".format(x+1)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
n, m = map(int, input().split())
p, y = [0]*m, [0]*m
dict_p = {}
for i in range(m):
    p[i], y[i] = map(int, input().split())
    if p[i] not in dict_p.keys():
        dict_p[p[i]] = list()

    dict_p[p[i]].append(y[i])
#print(dict_p)
ans = [0]*m
for i in range(m):
    dict_p[p[i]].sort()

for i in range(m):
    x = bisect_left(dict_p[p[i]], y[i])
    ans = "{:006}".format(p[i]) + "{:006}".format(x+1)
    print(ans)


Fixed submission:
from bisect import bisect_left
from collections import defaultdict
n, m = map(int, input().split())
py = []
dict_p = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
    dict_p[p].append(y)
#print(dict_p)
for values in dict_p.values():
    values.sort()

for p, y in py:
    x = bisect_left(dict_p[p], y)
    ans = "{:006}".format(p) + "{:006}".format(x+1)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
n, m = map(int, input().split())
p, y = [0]*m, [0]*m
dict_p = {}
for i in range(m):
    p[i], y[i] = map(int, input().split())
    if p[i] not in dict_p.keys():
        dict_p[p[i]] = list()

    dict_p[p[i]].append(y[i])
#print(dict_p)
ans = [0]*m
for i in range(m):
    dict_p[p[i]].sort()
    x = bisect_left(dict_p[p[i]], y[i])
    ans = "{:006}".format(p[i]) + "{:006}".format(x+1)
    print(ans)


Fixed submission:
from bisect import bisect_left
from collections import defaultdict
n, m = map(int, input().split())
py = []
dict_p = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
    dict_p[p].append(y)
#print(dict_p)
for values in dict_p.values():
    values.sort()

for p, y in py:
    x = bisect_left(dict_p[p], y)
    ans = "{:006}".format(p) + "{:006}".format(x+1)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
p, y = [0]*m, [0]*m
dict_p = {}
for i in range(m):
    p[i], y[i] = map(int, input().split())
    if p[i] not in dict_p.keys():
        dict_p[p[i]] = list()

    dict_p[p[i]].append(y[i])
#print(dict_p)
ans = [0]*m
for i in range(m):
    dict_p[p[i]].sort()
    l = 0
    r = len(dict_p[p[i]])
    while r-l > 1:
        mid = (l+r)//2
        if dict_p[p[i]][mid] <= y[i]:
            l = mid
        elif dict_p[p[i]][mid] > y[i]:
            r = mid

    i0 = l + 1
    p0 = p[i]
    ans = str("{:0=6}".format(p0)) + str("{:0=6}".format(i0))
    print(ans)

Fixed submission:
from bisect import bisect_left
from collections import defaultdict
n, m = map(int, input().split())
py = []
dict_p = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
    dict_p[p].append(y)
#print(dict_p)
for values in dict_p.values():
    values.sort()

for p, y in py:
    x = bisect_left(dict_p[p], y)
    ans = "{:006}".format(p) + "{:006}".format(x+1)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
p, y = [0]*m, [0]*m
dict_p = {}
for i in range(m):
    p[i], y[i] = map(int, input().split())
    if p[i] not in dict_p.keys():
        dict_p[p[i]] = list()

    dict_p[p[i]].append(y[i])
#print(dict_p)
ans = [0]*m
for i in range(m):
    dict_p[p[i]].sort()
    r = dict_p[p[i]].index(y[i]) + 1
    l = p[i]
    ans = str("{:0=6}".format(l)) + str("{:0=6}".format(r))
    print(ans)

Fixed submission:
from bisect import bisect_left
from collections import defaultdict
n, m = map(int, input().split())
py = []
dict_p = defaultdict(list)
for i in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
    dict_p[p].append(y)
#print(dict_p)
for values in dict_p.values():
    values.sort()

for p, y in py:
    x = bisect_left(dict_p[p], y)
    ans = "{:006}".format(p) + "{:006}".format(x+1)
    print(ans)