Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
d={i+1:[[],[]] for i in range(n)}
for i in range(m):
     p,y=map(int,input().split())
     idx=bisect.bisect_left(d[p][0],y)
     d[p][0].insert(idx,y)
     d[p][1].insert(idx,i)
tmp2=[0 for i in range(m)]
for k in d.keys():
     x=d[k][1]
     for i in range(len(x)):
          num=str(k).zfill(6)+str(i+1).zfill(6)
          tmp2[x[i]]=num
for x in tmp2:
     print(x)

Fixed submission:
import bisect
n,m=map(int,input().split())
d=[]
for i in range(m):
     p,y=map(int,input().split())
     d.append([p,y,i])
d=sorted(d,key=lambda x:(x[0],x[1]))
tmp2=[0 for i in range(m)]
p_=0
cnt=0
for x in d:
     p,y,i=x
     if p_!=p:
          p_=p
          cnt=0
     cnt+=1
     tmp2[i]=str(p).zfill(6)+str(cnt).zfill(6)
for x in tmp2:
     print(x)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
d={i+1:[[],[]] for i in range(n)}
for i in range(m):
     p,y=map(int,input().split())
     idx=bisect.bisect_left(d[p][0],y)
     d[p][0].insert(idx,y)
     d[p][1].insert(idx,i)
tmp2=[0 for i in range(m)]
for k in d.keys():
     x=d[k][1]
     for i in range(len(x)):
          num=str(k).zfill(6)+str(i+1).zfill(6)
          tmp2[x[i]]=num
for x in tmp2:
     print(x)

Fixed submission:
import bisect
n,m=map(int,input().split())
d=[]
for i in range(m):
     p,y=map(int,input().split())
     d.append([p,y,i])
d=sorted(d,key=lambda x:(x[0],x[1]))
tmp2=[0 for i in range(m)]
p_=0
cnt=0
for x in d:
     p,y,i=x
     if p_!=p:
          p_=p
          cnt=0
     cnt+=1
     tmp2[i]=str(p).zfill(6)+str(cnt).zfill(6)
for x in tmp2:
     print(x)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
d={i+1:[[],[]] for i in range(n)}
for i in range(m):
     p,y=map(int,input().split())
     idx=bisect.bisect_left(d[p][0],y)
     d[p][0].insert(idx,y)
     d[p][1].insert(idx,i)
tmp=[]
tmp2=[]
for k in d.keys():
     for i in range(len(d[k][0])):
          num=str(k).zfill(6)+str(i+1).zfill(6)
          idx=bisect.bisect_left(tmp,d[k][1][i])
          tmp.insert(idx,d[k][1][i])
          tmp2.insert(idx,num)
for x in tmp2:
     print(x)

Fixed submission:
import bisect
n,m=map(int,input().split())
d=[]
for i in range(m):
     p,y=map(int,input().split())
     d.append([p,y,i])
d=sorted(d,key=lambda x:(x[0],x[1]))
tmp2=[0 for i in range(m)]
p_=0
cnt=0
for x in d:
     p,y,i=x
     if p_!=p:
          p_=p
          cnt=0
     cnt+=1
     tmp2[i]=str(p).zfill(6)+str(cnt).zfill(6)
for x in tmp2:
     print(x)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
d={i+1:[[],[]] for i in range(n)}
for i in range(m):
     p,y=map(int,input().split())
     idx=bisect.bisect_left(d[p][0],y)
     d[p][0].insert(idx,y)
     d[p][1].insert(idx,i)
tmp=[]
tmp2=[]
for k in d.keys():
     for i in range(len(d[k][0])):
          num=str(k).zfill(6)+str(i+1).zfill(6)
          idx=bisect.bisect_left(tmp,d[k][1][i])
          tmp.insert(idx,d[k][1][i])
          tmp2.insert(idx,num)
for x in tmp2:
     print(x)

Fixed submission:
import bisect
n,m=map(int,input().split())
d=[]
for i in range(m):
     p,y=map(int,input().split())
     d.append([p,y,i])
d=sorted(d,key=lambda x:(x[0],x[1]))
tmp2=[0 for i in range(m)]
p_=0
cnt=0
for x in d:
     p,y,i=x
     if p_!=p:
          p_=p
          cnt=0
     cnt+=1
     tmp2[i]=str(p).zfill(6)+str(cnt).zfill(6)
for x in tmp2:
     print(x)