Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import numpy as np
def argsort_p1(ls):
    return [sorted(ls).index(t)+1 for t in ls]
N,M = list(map(int,input().split()))
P = []
Y = []
for m in range(M):
    p,y = list(map(int,input().split()))
    P.append(p)
    Y.append(y)
ls = [ [] for _ in range(max(P))]
ls_idx = [ [] for _ in range(max(P))]
for p,y in zip(P,Y):
    ls[p-1].append(y)
    ls_idx[p-1].append(len(ls_idx[p-1]))
ls_dict = []
new_dict = {}
for i,line in enumerate(ls):
    arg_line = argsort_p1(line)
    for arg in arg_line:
        new_dict[str(i+1)+"/"+str(sorted(line)[arg-1])]=str(i+1).zfill(6)+str(arg).zfill(6)
for p,y in zip(P,Y):
    print (new_dict[str(p)+"/"+str(y)])


Fixed submission:
N, M = map(int,input().split())
ls = []
for m in range(M):
    p, y = map(int,input().split())
    ls.append([p,y])
sorted_ls = sorted(ls,key=lambda x:x[1])
counter = [0 for i in range(N+1)]
d = {}
for p,y in sorted_ls:
    counter[p]+=1
    num = counter[p]
    d[y] = num
for p,y in ls:
    #print (p,d[y])
    print (str(p).zfill(6)+str(d[y]).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import numpy as np
def argsort_p1(ls):
    return [sorted(ls).index(t)+1 for t in ls]


N,M = list(map(int,input().split()))
P = []
Y = []
for m in range(M):
    p,y = list(map(int,input().split()))
    P.append(p)
    Y.append(y)
#print (P,Y)
ls = [ [] for _ in range(max(P))]
ls_idx = [ [] for _ in range(max(P))]
#print (ls)
for p,y in zip(P,Y):
    ls[p-1].append(y)
    ls_idx[p-1].append(len(ls_idx[p-1]))
ls_dict = []
new_dict = {}
for i,line in enumerate(ls):
    #arg_line = np.argsort(line)+1
    arg_line = argsort_p1(line)
    #print (arg_line)
    temp_dict = dict(zip(line, arg_line))
    ls_dict.append(temp_dict)
    for arg in arg_line:
        #print (line[arg-1])
        new_dict[str(i+1)+"/"+str(sorted(line)[arg-1])]=str(i+1).zfill(6)+str(arg).zfill(6)
#print (new_dict)
#print (ls_dict)
for p,y in zip(P,Y):
#    print (str(p).zfill(6)+str(ls_dict[p-1][y]).zfill(6))
    print (new_dict[str(p)+"/"+str(y)])


Fixed submission:
N, M = map(int,input().split())
ls = []
for m in range(M):
    p, y = map(int,input().split())
    ls.append([p,y])
sorted_ls = sorted(ls,key=lambda x:x[1])
counter = [0 for i in range(N+1)]
d = {}
for p,y in sorted_ls:
    counter[p]+=1
    num = counter[p]
    d[y] = num
for p,y in ls:
    #print (p,d[y])
    print (str(p).zfill(6)+str(d[y]).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
#import numpy as np
def argsort_p1(ls):
    return [sorted(ls).index(t)+1 for t in ls]

N,M = list(map(int,input().split()))
P = []
Y = []

for m in range(M):
    p,y = list(map(int,input().split()))
    P.append(p)
    Y.append(y)
#print (P,Y)
ls = [ [] for _ in range(max(P))]
temp = [ [] for _ in range(max(P))]
ls_idx = []
#print (ls)
for p,y in zip(P,Y):
    ls[p-1].append(y)
    ls_idx.append(len(temp[p-1]))
    temp[p-1].append(len(temp[p-1]))
#print (ls_idx)
#ls_dict = []
# ls_arg_line = []
# for line in ls:
#
#     ls_arg_line.append(argsort_p1(line))
ls_arg_line = [argsort_p1(line) for line in ls]
for i,(p,y) in enumerate(zip(P,Y)):
    #print (i,p,y)
    print (str(p).zfill(6)+str(ls_arg_line[p-1][ls_idx[i]]).zfill(6))


Fixed submission:
N, M = map(int,input().split())
ls = []
for m in range(M):
    p, y = map(int,input().split())
    ls.append([p,y])
sorted_ls = sorted(ls,key=lambda x:x[1])
counter = [0 for i in range(N+1)]
d = {}
for p,y in sorted_ls:
    counter[p]+=1
    num = counter[p]
    d[y] = num
for p,y in ls:
    #print (p,d[y])
    print (str(p).zfill(6)+str(d[y]).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import numpy as np
def argsort_p1(ls):
    a = sorted(ls)
    r = [a.index(t)+1 for t in ls]
    return r

N,M = list(map(int,input().split()))
P = []
Y = []
for m in range(M):
    p,y = list(map(int,input().split()))
    P.append(p)
    Y.append(y)
#print (P,Y)
ls = [ [] for _ in range(max(P))]
#print (ls)
for p,y in zip(P,Y):
    ls[p-1].append(y)
ls_dict = []
for line in ls:
    #arg_line = np.argsort(line)+1
    arg_line = argsort_p1(line)
    temp_dict = dict(zip(line, arg_line))
    ls_dict.append(temp_dict)
#print (ls_dict)
for p,y in zip(P,Y):
    print (str(p).zfill(6)+str(ls_dict[p-1][y]).zfill(6))


Fixed submission:
N, M = map(int,input().split())
ls = []
for m in range(M):
    p, y = map(int,input().split())
    ls.append([p,y])
sorted_ls = sorted(ls,key=lambda x:x[1])
counter = [0 for i in range(N+1)]
d = {}
for p,y in sorted_ls:
    counter[p]+=1
    num = counter[p]
    d[y] = num
for p,y in ls:
    #print (p,d[y])
    print (str(p).zfill(6)+str(d[y]).zfill(6))