Problem:


Score: 300 points

Problem Statement

In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.

City i is established in year Y_i and belongs to Prefecture P_i.

You can assume that there are no multiple cities that are established in the same year.

It is decided to allocate a 12-digit ID number to each city.

If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.

Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.

Find the ID numbers for all the cities.

Note that there can be a prefecture with no cities.

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq P_i \leq N

1 \leq Y_i \leq 10^9

Y_i are all different.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
P_1 Y_1
:
P_M Y_M

Output

Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).

Sample Input 1

2 3
1 32
2 63
1 12

Sample Output 1

000001000002
000002000001
000001000001

As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.

As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.

As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.

Sample Input 2

2 3
2 55
2 77
2 99

Sample Output 2

000002000001
000002000002
000002000003



Sample input:
2 3
1 32
2 63
1 12


Sample output:
000001000002
000002000001
000001000001

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

def zeroume(a, b):
    a, b = str(a), str(b)
    txt = ""
    for _ in range(6 - len(a)):
        txt += "0"
    txt += a
    for _ in range(6 - len(b)):
        txt += "0"
    txt += b
    return txt

if __name__ == "__main__":
    dum = list(map(int, input().split()))
    n, m = dum[0], dum[1]

    whole = [0. for _ in range(m)]
    keyset = set()
    keys = []
    values = []
    for i in range(m):
        dum = list(map(int, input().split()))
        whole[i] = dum

        n_dum, m_dum = dum[0], dum[1]
        if n_dum in keyset:
            num = keys.index(n_dum)
            values[num].append(m_dum)

        else:
            keys.append(n_dum)
            values.append([m_dum])

    for i in range(len(values)):
        values[i] = sorted(values[i])

    for i in range(m):
        n_dum, m_dum = whole[i][0], whole[i][1]
        print(zeroume(n_dum, values[keys.index(n_dum)].index(m_dum)+1))

Submission status: Runtime Error

Solution code:
N, M =map(int, input().split())
Ps =[]
Ys =[]
dic = {}
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls = dic.get(p, [])
    ls.append(y)
for p in Ps:
    ls = dic[p]
    ls.sort()
    dic[p] = ls
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = dic[p].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import bisect

N,M = map(int,input().split())

P = []
Y = []
PY = []
dic = {}
for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

    dic[y] = ''

    PY.append((p,y))

PY = sorted(PY)
P  = sorted(P)
lenP = len(P)
left = 0
righ = 0
for i in range(1,N+1):

    t_list = []

    left = bisect.bisect_left(P,i,righ,lenP)
    righ = bisect.bisect_right(P,i,left,lenP)

    # print(i,P)
    # print(left,righ)

    if i == P[left]:
        for j in range(left,righ):
            t_list.append(PY[j][1])
        t_list = sorted(t_list)
        for k in range(len(t_list)):
            y = t_list[k]
            dic[y] = str(i).zfill(6) + str(k+1).zfill(6)

for y in Y:
    print(dic[y])

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
P = []
Y = []
O = [[] for i in range(N)]

for i in range(M):
    p,y = map(int, input().split())
    P.append(p)
    Y.append(y)
    O[p-1].append(y)
    O[p-1].sort()

for i,p in enumerate(P):
    s = (6 - len(str(p))) * "0"
    s += str(p)
    s += (6 - len(str((O[p-1].index(Y[p-1])) + 1))) * "0"
    s += str((O[p-1].index(Y[i])) + 1)
    print( s )

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
check = [[] for i in range(M+1)]
P, Y = [0]*M, [0]*M

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    check[P[i]].append(Y[i]) 

for i in range(1, M+1):
    check[i].sort()

for i in range(0, M):
    check[P[i]].sort()
    num = check[P[i]].index(Y[i])+1
    mae = ((6-len(str(num)))*'0')+str(P[i])
    ato = ((6-len(str(P[i])))*'0')+str(num)
    print(mae+ato)

Submission status: Runtime Error

Solution code:
N, M = (int(i) for i in input().split(' '))
py=[]
p =[]

# 全都市を配列に代入
for i in range(M):
    p = [i]
    p.extend([int(j) for j in input().split(' ')])
    py.append(p)

# 設立年で一度ソートする
py.sort(key = lambda x: x[2])
pcid = [1] * M # 各県の都市ID

for i in range(M):
    p = py[i][1] # 県ID
    py[i][2] = pcid[p-1]
    pcid[p-1] += 1

py.sort(key=lambda x:x[0])
for t in py:
    print('{0:0>6}{1:0>6}'.format(t[1],t[2]))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

p_list = []
y_list = []
shi_map = {}

for i in range(M):
    p, y = map(int, input().split())
    p_list.append(p)
    y_list.append(y)
    if p in shi_map:
        shi_map[p].append(y)
    else:
        shi_map[p] = [y]
count_p = len(set(p_list))
shi_list = list(map(sorted, shi_map.values()))
for i in range(M):
    p = p_list[i]
    y = y_list[i]
    if p > count_p:
        s = shi_list[p - 1 - count_p]
    else:
        s = shi_list[p-1]
    j = s.index(y)
    p_str = str(p).zfill(6)
    j_str = str(j+1).zfill(6)
    print(p_str + j_str)

Submission status: Runtime Error

Solution code:
m = nm[1]
all_city = list()
for i in range(m):
    py = list(map(int, input().split()))
    py.append(i)
    all_city.append(py)
ac_list = copy.deepcopy(all_city)
ac_list.sort()
ac_dict = {}
a = 0
b = 0
for i in range(m):
    if ac_list[i][0] == a:
        b += 1
    else:
        a += 1
        b = 1
    ac_dict[ac_list[i][2]] = str(str(a).zfill(6) + str(b).zfill(6))
for i in range(m):
    print(ac_dict.get(all_city[i][2]))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

p_list = []
y_list = []
shi_map = {}

for i in range(M):
    p, y = map(int, input().split())
    p_list.append(p)
    y_list.append(y)
    if p in shi_map:
        shi_map[p].append(y)
    else:
        shi_map[p] = [y]
count_p = len(set(p_list))
shi_list = list(map(sorted, shi_map.values()))
for i in range(M):
    p = p_list[i]
    y = y_list[i]
    s = shi_list[p-1-count_p]
    j = s.index(y)
    p_str = str(p).zfill(6)
    j_str = str(j+1).zfill(6)
    print(p_str + j_str)

Submission status: Runtime Error

Solution code:
N, M =map(int, input().split())
Ps =[]
Ys =[]
dic = {}
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls = dic.get(p, [])
    ls.append(y)
    dic[p] = ls.sort()
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = dic[p].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
timeline = []
for i in range(M):
    P, Y = map(int, input().split())
    timeline.append((Y, P, i))
timeline.sort()
count = [0] * (N + 1)
number = [(0, 0)] * M
for y, p, i in timeline:
    count[p] += 1
    number[i] = (p, count[p])
for i in range(M):
    print(f'{number[i][0]:06}{number[i][1]:06}')

Submission status: Runtime Error

Solution code:
N ,M = map(int,input().split( ))
P = []
Y = []

l = []
for i in range(N):
	l.append([])

for i in range(M):
	p, y = map(int,input().split( ))
	P.append(p)
	Y.append(y)
	l[P[i]-1].append(Y[i])

for i in range(N):
	l[i].sort()


for i in range(M):
	Y[i] = l[P[i]-1].index(Y[i]) + 1
	while len(str(P[i])) < 6 :
		P[i] = '0' + str(P[i])
	while len(str(Y[i])) < 6 :
		Y[i] = '0' + str(Y[i])
	print(P[i] + Y[i])

Submission status: Runtime Error

Solution code:
import sys

in1 = sys.stdin.readline().split(' ')
N = int(in1[0])
M = int(in1[1])

cities = []
prefs = [[] for i in range(M)]

data = sys.stdin.readlines()

i = 0
for line in data:
  arr = line.split(' ')
  pi, yi = int(arr[0]), int(arr[1])

  cities.append([i, pi, yi])
  prefs[pi-1].append(yi)
  i += 1


i = 0
for pref in prefs:
  prefs[i] = list(sorted(pref))
  i += 1

for city in cities:
  pi, yi = city[1], city[2]
  print("%s%s" % (str(city[1]).zfill(6), str(prefs[pi-1].index(yi)+1).zfill(6)))

Submission status: Runtime Error

Solution code:
import numpy as np


N, M = map(int, input().split())

P = [None] * M
Y = [None] * M

X = [None] * (N + 1)
Y = [None] * (N + 1)

for n in range(N + 1):
    X[n] = []

for m in range(M):
    P[m], Y[m] = map(int, input().split())
    X[P[m]] = X[P[m]] + [Y[m]]

for i in range(len(X)):
    Y[i] = (np.argsort(np.array(X[i]))).tolist()

for p in P:
    print('%06d%06d' % (p, 1 + Y[p].pop(0)))

Submission status: Runtime Error

Solution code:
import sys
def main():
    lines = sys.stdin.readlines()
    plist = [0] * 100000

    n, m = map(int, lines[0].split())
    cities={}
    for i in range(1, m+1):
        p, y = map(int, lines[i].split())
        plist[i-1] = p
        if p in cities:
            idx=0
            for item in cities[p]:
                if item[0] > y:
                    item[1] += 1
                else:
                    idx += 1
            cities[p].append([y, idx])
            pass
        else:
            cities[p] = [[y, 0]]

    for p in plist[:n+1]:
        #print(p, cities[p])
        print("{:06d}{:06d}".format(p, cities[p][0][1]+1))
        del cities[p][0]
    return

main()

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))
tmp = [[0 for i in range(1)] for j in range(m)]
pys = []
for i in range(0, m):
    p, y = list(map(int, input().split()))
    tmp[p].append(y)
    pys.append([p, y])

print(tmp)

ttmp = [[0 for i in range(1)] for j in range(m)]

for i in range(m):
    ttmp[i] = sorted(tmp[i])

print(ttmp)

for py in pys:
    p, y = py
    yindex = ttmp[p].index(y)
    print('{:06}'.format(p) + '{:06}'.format(yindex))

Submission status: Runtime Error

Solution code:
N, M = (int(i) for i in input().split())

P = []
Y = []
a = {}
for m in range(M):
    p, y = (int(i) for i in input().split())
    a[p] = [*a[p], y] if p in a else [y]
    P.append(p)
    Y.append(y)


sa = {}
for k, v in a.items():
    V = sorted(v)
    sa[k] = V

cnt = 0
for i, a in enumerate(P):
    print('%06d' % a + '%06d' % (sa[a].index(Y[i]) + 1))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
data=[]
for m in range(M):
    data.append(list(map(int,input().split())))
    data[m].append(m)
data.sort(key=lambda x:x[1])

pref=0
for m in range(M):
    count+=1
    if data[m][0]!=pref:
        count=1
    pref=data[m][0]
    ID=('000000'+str(data[m][0]))[-6:]+('000000'+str(count))[-6:]
    data[m].append(ID)

data.sort(key=lambda x:x[2])

for m in range(M):
    print(data[m][3])

Submission status: Runtime Error

Solution code:
N, M = (int(i) for i in input().split(' '))
py=[]
p =[]

# 全都市を配列に代入
for i in range(M):
    p = [i]
    p.extend([int(j) for j in input().split(' ')])
    py.append(p)

# 全N個の県について調べる
Npy = []
for i in range(1,N+1):
    # 県i
    pyi = [j for j in py if j[1] == i] # 県iの市リスト
    pyi.sort(key=lambda x: x[2]) # 県iの市を生まれた年でソート
    l = len(pyi)
    cnt = 0
    for k in range(1,l+1):
        pyi[k-1][2] = k
    Npy.extend(pyi)

Npy.sort(key=lambda x: x[0])

for t in Npy:
    print('{0:0>8}{1:0>8'.format(t[1],t[2]))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
 
cities = []
 
for i in range(M):
    cities.append(list(map(int,input().split())))
 
sorted=[ [] for i in range(N+1) ]
for p,y in cities:
  sorted[p].append(y)
 
for s in sorted:
  s.sort()
 
for p,y in cities:
  for i in range(len(sorted[p])):
    if sorted[p][i]== y:

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
 
cities = []
 
for i in range(M):
    cities.append(list(map(int,input().split())))
 
sorted=[ [] for i in range(N) ]
for p,y in cities:
  sorted[p].append(y)
 
for s in sorted:
  s.sort()
 
for p,y in cities:
  for i in range(len(sorted[p])):
    if sorted[p][i]== y:

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
p=[[] for i in range(n)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(n):
    tl=p[i].sort()
    for j in range(len(p[i])):
        u=str(i+1)
        w=tl.index(p[i][j])
        d=str(w+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
P = []
Y = []
arr = [[]for j in range(10**5)]
for i in range(M):
  listA = list(map(int,input().split()))
  P.append(listA[0])
  Y.append(listA[1])
  arr[listA[0]].append(listA[1])
  arr[listA[0]].sort()
for i in range(M):
  num = Y[i]
  for k in range(M):
    if arr[P[i]][k] == Y[i]:
      break
  print(str(P[i]).rjust(6,'0')+str(k+1).rjust(6,'0'))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
P = []
Y = []
arr = [[]for j in range(10**5)]
for i in range(M):
  listA = list(map(int,input().split()))
  P.append(listA[0])
  Y.append(listA[1])
  arr[listA[0]].append(listA[1])
  arr[listA[0]].sort()
for i in range(M):
  num = Y[i]
  for k in range(M):
    if arr[P[i]][k] == Y[i]:
      break
  print(str(P[i]).rjust(6,'0')+str(k+1).rjust(6,'0'))
print(arr)

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = map(int, input().split())

city_dict = {}
for i in range(n):
    city_dict[i] = []

ps = []
ys = []
cities = []
for i in range(m):
    p, y = map(int, input().split())
    city_dict[p].append(y)
    cities.append([p, y])

for city in cities:
    print('{0:06d}{1:06d}'.format(city[0], np.argsort(city_dict[city[0]])[city_dict[city[0]].index(city[1])] + 1))

Submission status: Runtime Error

Solution code:
N ,M = map(int,input().split( ))
P = []
Y = []
for i in range(M):
	p, y = map(int,input().split( ))
	P.append(p)
	Y.append(y)

l = []

for i in range(N):
	l.append([])

for i in range(M):
	l[P[i]-1].append(Y[i])

for i in range(N):
	l[i].sort()

for i in range(M):
	Y[i] = l[P[i]-1].index(Y[i]) + 1

for i in range(M):
	while len(str(P[i])) < 6 :
		P[i] = '0' + str(P[i])

for i in range(M):
	while len(str(Y[i])) < 6 :
		Y[i] = '0' + str(Y[i])

for i in range(M):
	print(P[i] + Y[i])

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())
arr=[]
arr1=[[] for i in range(10000)]
for i in range(p):
    arr.append(list(map(int,input().split())))
    arr1[arr[i][0]].append(arr[i][1])
for i in range(10000):
    arr1[i].sort()
for i in range(p):
    print("%06d%06d"%(arr[i][0],arr1[arr[i][0]].index(arr[i][1])+1))

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = map(int, input().split())

city_dict = {}
for i in range(m):
    city_dict[i] = []

ps = []
ys = []
cities = []
for i in range(m):
    p, y = map(int, input().split())
    city_dict[p].append(y)
    cities.append([p, y])

for city in cities:
    print('{0:06d}{1:06d}'.format(city[0], np.argsort(city_dict[city[0]])[city_dict[city[0]].index(city[1])] + 1))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())

l1 = [[] for i in range(n)]
l2 = []

for i in range(m):
    p,y = map(int,input().split())
    l1[p].append(y)
    l2.append((p,y))

for p in range(n):
    l1[p].sort()

for i in range(m):
    p = l2[i][0]
    k = l1[p].index(l2[i][1])+1
    p = str(p)
    k = str(k)
    ans = "0"*(6-len(p))+p+"0"*(6-len(k))+k
    print(ans)

Submission status: Runtime Error

Solution code:
import pandas as pd

n, m = map(int, input().split())

p = []
y = []

for i in range(n):
    pi, yi = map(int, input().split):
    p.append(pi)
    y.append(yi)


df = pd.DataFrame({"p": p, "y": y})

df["ranked"] = df.groupby("p").rank()

for i in range(n):
    print(str(df.iloc[0].p.astype(int)).zfill(6) + str(df.iloc[0].ranked.astype(int)).zfill(6))

Submission status: Runtime Error

Solution code:
N,N=map(int,input().split())

cities = []

for i in range(N):
    cities.append(list(map(int,input().split())))

sorted=[ [] for i in range(N) ]
for p,y in cities:
  sorted[p].append(y)

for s in sorted:
  s.sort()

for p,y in cities:
  for i in range(len(sorted[p])):
    if sorted[p][i]== y:
        id_y = i

  print('{0:06d}{1:06d}'.format(p,id_y+1))

Submission status: Runtime Error

Solution code:
import numpy as np
N, M = [int(a) for a in input().split()]
P = []
Y = []

for _ in range(M):
    p, y =  [int(a) for a in input().split()]
    P.append(p)
    Y.append(y)

index = [1 for _ in range(len(P))]
id = ["" for _ in range(len(P))]

for i in np.argsort(Y):
    id[i] = "{0:06d}".format(P[i])+"{0:06d}".format(index[P[i]])
    index[P[i]] += 1

for i in id:
    print(i)

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = list(map(int, input().split(" ")))
p = m*[0]
y = m*[0]
ken = [[0] for i in range(n)]
for i in range(m):
    p[i], y[i] = list(map(int, input().split(" ")))
    ken[p[i]-1].append(y[i])

ken = np.array(ken)

for i in range(n):
    ken[i].sort()


for i in range(m):
    print("%06d%06d" %(p[i], ken[p[i]-1].index(y[i])))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
p = []
y = []
data = dict()

ans = dict()
for i in range(n):
    data[i+1] = []
for i in range(m):
    ptemp,ytemp = map(int,input().split())
    p.append(ptemp)
    y.append(ytemp)
    data[ptemp].append(ytemp)
    ans[ytemp] = []

for i in data:
    if len(data[i]) != 0:
        data[i].sort()

for i in data:
    for k in range(len(data[i])):
        moji = []
        if len(str(i)) != 6:
            for j in range(6-len(str(i))):
                moji.append("0")
        moji.append(str(i))
        if len(str(k+1)) != 6:
            for j in range(6-len(str(k+1))):
                moji.append("0")
        moji.append(str(k+1))
        ans[data[i][k]].append(moji)

for i in range(m):
    for k in range(12):
        if k != 11:
            print(ans[y[i]][0][k],end = "")
        else:
            print(ans[y[i]][0][k])

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())

l1 = [[] for i in range(m)]
l2 = []

for i in range(m):
    p,y = map(int,input().split())
    l1[p].append(y)
    l2.append((p,y))

for p in range(n):
    l1[p].sort()

for i in range(m):
    p = l2[i][0]
    k = l1[p].index(l2[i][1])+1
    p = str(p)
    k = str(k)
    ans = "0"*(6-len(p))+p+"0"*(6-len(k))+k
    print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
PY = [[int(py) for py in input().split()] for _ in range(M)]

for i in range(1,M+1):
    PY[i-1].append(i)

PY.sort(key=lambda x:x[1])

count = [1 for _ in range(M)]

ans = []

for cell in PY:
    row = '{0:06d}'.format(cell[0]) + '{0:06d}'.format(count[cell[0]-1])
    ans.append([row,cell[2]])
    count[cell[0]-1] += 1


ans.sort(key=lambda x:x[1])

for row in ans:
    print(row[0])

Submission status: Runtime Error

Solution code:
def get_line():
  return input().split(' ')

class element:
  def __init__(self, P, Y, idx):
    self.P = P
    self.Y = Y
    self.idx = idx
  def __lt__(self, other):
    return self.Y < other.Y

N, M = map(int, get_line())
els = [0] * M
for i in range(M):
  p, y = map(int, get_line())
  els[i] = Element(p, y, i)

p_map = [[] for _ in range(N)]

for e in els:
  p_map[e.P - 1].append(e)

ans = [0] * M

for mp in p_map:
  cnt = 1
  for e in sorted(mp):
    ans[e.idx] = "{:06d}{:06d}".format(e.P, cnt)
    cnt = cnt + 1

for e in ans:
  print(e)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
p=[[] for i in range(m)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(m):
    for j in range(len(p[i])):
        u=str(i+1)
        d=str(j+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

Submission status: Runtime Error

Solution code:
nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])

N = [0 for i in range(n)]
for i in range(m):
  c = input().split(' ')
  ID = '0'*(6 - int(len(c[0]))) + c[0]
  N[int(c[0])-1] += 1
  ID += '0'*(6 - int(len(str(N[int(c[0]-1)])))) + str(N[int(c[0]-1)])
  print(ID)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
PY = [[int(py) for py in input().split()] for _ in range(M)]

for i in range(1,M+1):
    PY[i-1].append(i)

PY.sort(key=lambda x:x[1])

count = [1 for _ in range(M)]

ans = []

for cell in PY:
    row = '{0:06d}'.format(cell[0]) + '{0:06d}'.format(count[cell[0]])
    ans.append([row,cell[2]])
    count[cell[0]] += 1


ans.sort(key=lambda x:x[1])

for row in ans:
    print(row[0])

Submission status: Runtime Error

Solution code:
nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])

N = [0 for i in range(n)]
for i in range(m):
  c = input().split(' ')
  ID = '0'*(6 - len(c[0])) + c[0]
  N[int(c[0])-1] += 1
  ID += '0'*(6 - len(str(N[int(c[0]-1)]))) + str(N[int(c[0]-1)])
  print(ID)

Submission status: Runtime Error

Solution code:
import numpy as np


N, M = map(int, input().split())

P = [None] * M
Y = [None] * M

X = [None] * (N + 1)
Y = [None] * (N + 1)

for n in range(N + 1):
    X[n] = []

for m in range(M):
    P[m], Y[m] = map(int, input().split())
    X[P[m]] = X[P[m]] + [Y[m]]

for i in range(len(X)):
    Y[i] = (np.argsort(np.array(X[i])) + 1).tolist()

for p in P:
    print('%06d%06d' % (p, Y[p].pop(0)))

Submission status: Runtime Error

Solution code:
import collections
n,m = map(int, input().split())
l=[]
for i in range(m):
  p,y = map(int, input().split())
  l.append((i,p,y))
l.sort(key=lambda x:x[2])
r={}
c = collections.Counter()
for i,p,y in l:
  c[p] += 1
  r[i] = (p, c[p])

for i in range(m):
  print(f"{str(r[i][0]).rjust(10,'0')}{str(r[i][1]).rjust(10,'0')}")

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
pys = []
for i in range(m):
    x = na()
    x = [x[0], x[1], i]
    pys.append(x)

pys.sort()
pp = -1
lid = 0
ans = [0] * m
for i in range(m):
    if pys[i][0] == pp:
        lid += 1
    else:
        lid = 1
    ans[pys[i][2]] = pys[i][0] * 1000000 + lid
    pp = pys[i][0]
for v in ans:
    print(f"{v:012d}")