Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

tmpsort = [[0]for i in range(n)]
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmpsort[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

for i in range(n):
    tmpsort[i].sort()
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))

Fixed submission:
N,M = map(int, input().split())  
piys = [[] for _ in range(N)]   
for i in range(M):  
    p, y = map(int, input().split())  
    piys[p-1].append((y,i))  

ans = [None]*M  
for p,iys in enumerate(piys):  
    iys.sort()  
    for k,(y,i) in enumerate(iys):  
        ans[i] = "%06d%06d" % (p+1,k+1)  

for i in ans:  
    print(i)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())

tmpsort = [[0]for i in range(n)]
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmpsort[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

for i in range(m):
    tmpsort[i].sort()
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))

Fixed submission:
N,M = map(int, input().split())  
piys = [[] for _ in range(N)]   
for i in range(M):  
    p, y = map(int, input().split())  
    piys[p-1].append((y,i))  

ans = [None]*M  
for p,iys in enumerate(piys):  
    iys.sort()  
    for k,(y,i) in enumerate(iys):  
        ans[i] = "%06d%06d" % (p+1,k+1)  

for i in ans:  
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

tmp_list = [[0]for i in range(n)]
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmp_list[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

import copy
tmpsort = copy.deepcopy(tmp_list)
for i in range(len(tmp_list)):
    tmpsort[i].sort()
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))

Fixed submission:
N,M = map(int, input().split())  
piys = [[] for _ in range(N)]   
for i in range(M):  
    p, y = map(int, input().split())  
    piys[p-1].append((y,i))  

ans = [None]*M  
for p,iys in enumerate(piys):  
    iys.sort()  
    for k,(y,i) in enumerate(iys):  
        ans[i] = "%06d%06d" % (p+1,k+1)  

for i in ans:  
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

tmp_list = [[0]for i in range(n)]
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmp_list[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

import copy
tmpsort = copy.deepcopy(tmp_list)
for i in range(len(tmp_list)):
    tmpsort[i].sort()
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((6-len(str(p_list[i])))*'0' + str(p_list[i]) + (6-len(str(idx)))*'0' + str(idx))

Fixed submission:
N,M = map(int, input().split())  
piys = [[] for _ in range(N)]   
for i in range(M):  
    p, y = map(int, input().split())  
    piys[p-1].append((y,i))  

ans = [None]*M  
for p,iys in enumerate(piys):  
    iys.sort()  
    for k,(y,i) in enumerate(iys):  
        ans[i] = "%06d%06d" % (p+1,k+1)  

for i in ans:  
    print(i)