Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
d = {}
l = [[] for i in range(M)]
for i in range(M):
    P,Y = map(str, input().split())
    P = "0" * (6-len(P)) + P
    d[P] += [int(Y)]
    l[i] = [P,int(Y)]
for i in range(M):
    tmp = str((sorted(d[l[i][0]]).index(l[i][1]))+1)
    print(l[i][0] + "0" * (6-len(tmp)) + tmp)

Fixed submission:
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
for i in range(M):
    P,Y = map(int, input().split())
    d[P].append([Y,i])
l = [0 for i in range(M)] 
cnt = 0   
for key in d:
    data = sorted(d[key])
    tmp = 0
    for i in range(len(data)):
        l[cnt] = [str(key).zfill(6) + str(tmp+1).zfill(6), data[i][1]]
        cnt += 1
        tmp += 1
l.sort(key = lambda x: x[1])
for i in range(M):
    print(l[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
l = [[] for i in range(M)]
for i in range(M):
    P,Y = map(str, input().split())
    P = "0" * (6-len(P)) + P
    d[P] += [int(Y)]
    l[i] = [P,int(Y)]
for i in range(M):
    tmp = str((sorted(d[l[i][0]]).index(l[i][1]))+1)
    print(l[i][0] + "0" * (6-len(tmp)) + tmp)

Fixed submission:
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
for i in range(M):
    P,Y = map(int, input().split())
    d[P].append([Y,i])
l = [0 for i in range(M)] 
cnt = 0   
for key in d:
    data = sorted(d[key])
    tmp = 0
    for i in range(len(data)):
        l[cnt] = [str(key).zfill(6) + str(tmp+1).zfill(6), data[i][1]]
        cnt += 1
        tmp += 1
l.sort(key = lambda x: x[1])
for i in range(M):
    print(l[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
l = [[] for i in range(M)]
for i in range(M):
    P,Y = map(str, input().split())
    P = "0" * (6-len(P)) + P
    d[P] += [int(Y)]
    l[i] = [P,int(Y)]
for i in range(M):
    tmp = str((sorted(d[l[i][0]]).index(l[i][1]))+1)
    print(l[i][0] + "0" * (6-len(tmp)) + tmp)

Fixed submission:
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
for i in range(M):
    P,Y = map(int, input().split())
    d[P].append([Y,i])
l = [0 for i in range(M)] 
cnt = 0   
for key in d:
    data = sorted(d[key])
    tmp = 0
    for i in range(len(data)):
        l[cnt] = [str(key).zfill(6) + str(tmp+1).zfill(6), data[i][1]]
        cnt += 1
        tmp += 1
l.sort(key = lambda x: x[1])
for i in range(M):
    print(l[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
l = [[] for i in range(M)]
for i in range(M):
    P,Y = map(str, input().split())
    P = "0" * (6-len(P)) + P
    d[P].append(int(Y))
    l[i] = [P,int(Y)]
for i in range(M):
    tmp = str((sorted(d[l[i][0]]).index(l[i][1]))+1)
    print(l[i][0] + "0" * (6-len(tmp)) + tmp)

Fixed submission:
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
for i in range(M):
    P,Y = map(int, input().split())
    d[P].append([Y,i])
l = [0 for i in range(M)] 
cnt = 0   
for key in d:
    data = sorted(d[key])
    tmp = 0
    for i in range(len(data)):
        l[cnt] = [str(key).zfill(6) + str(tmp+1).zfill(6), data[i][1]]
        cnt += 1
        tmp += 1
l.sort(key = lambda x: x[1])
for i in range(M):
    print(l[i][0])