Buggy python submission (verdict: Time Limit Exceeded):
import bisect as bi
n,m = map(int,input().split())
dic={}
P,Y = [],[]
for i in range(m):
  p,y = map(int,input().split())
  P.append(p)
  Y.append(y)
  target = dic.get(p) if dic.get(p)!=None else []
  target.append(y)
  dic[p] = target

def fill_zero(num):
  s = str(num)
  dif = 6-len(s)
  return '0'*dif+s
  
for i in range(m):
  li = sorted(dic[P[i]])
  #ord = li.index(Y[i])+1
  ord = bi.bisect_left(li, Y[i])+1
  print(fill_zero(P[i])+fill_zero(ord))
  

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

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
dic={}
P,Y = [],[]
for i in range(m):
  p,y = map(int,input().split())
  P.append(p)
  Y.append(y)
  target = dic.get(p) if dic.get(p)!=None else []
  target.append(y)
  dic[p] = target

def fill_zero(num):
  s = str(num)
  dif = 6-len(s)
  return '0'*dif+s
  
for i in range(m):
  li = sorted(dic[P[i]])
  ord = li.index(Y[i])+1
  print(fill_zero(P[i])+fill_zero(ord))
  
  

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

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
dic={}
P,Y = [],[]
for i in range(m):
  p,y = map(int,input().split())
  P.append(p)
  Y.append(y)
  target = dic.get(p) if dic.get(p)!=None else []
  target.append(y)
  dic[p] = target

def fill_zero(num):
  s = str(num)
  dif = 6-len(s)
  return '0'*dif+s
  
for i in range(m):
  li = sorted(dic[P[i]])  
  ord = li.index(Y[i])+1
  print(fill_zero(P[i])+fill_zero(ord))
  
  

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

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
  P[PY[i][0]-1].sort()
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))


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

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
  P[PY[i][0]-1].sort()
print(P)
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))


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

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
ans = []
sort_P = []
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
for i in range(len(P)):
  sort_P.append(sorted(P[i]))
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = sort_P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))


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

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')