Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    iPY[i] = (i, *map(int, input().split()))
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = [tuple(map(int, input().split())) for _ in range(M)]
for s1, s2 in shi:
    ken[s1-1].append(s2)
for k in ken:
    k.sort()
for s1, s2 in shi:
    print("{:06}{:06}".format(s1, ken[s1-1].index(s2)+1))

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = [tuple(map(int, input().split())) for _ in range(M)]
for s1, s2 in shi:
    ken[s1-1].append(s2)
for k in ken:
    k.sort()
for s1, s2 in shi:
    print("{:06}{:06}".format(s1, ken[s1-1].index(s2+1)))

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = []
for _ in range(M):
    P, Y = map(int, input().split())
    ken[P-1].append(Y)
    shi.append((P, Y))
for k in ken:
    k.sort()
for s1, s2 in shi:
    print("{:06}{:06}".format(s1, ken[s1-1].index(s2)+1))

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = []
for _ in range(M):
    P, Y = map(int, input().split())
    ken[P-1].append(Y)
    shi.append((P, Y))
for k in ken:
    k.sort()
for s in shi:
    print("{:06}{:06}".format(s[0], ken[s[0]-1].index(s[1])+1))

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = []
for _ in range(M):
    P, Y = map(int, input().split())
    ken[P-1].append(Y)
    shi.append((P, Y))
for k in ken:
    k.sort()
for s in shi:
    print("{:06}{:06}".format(s[0], ken[s[0]-1].index(s[1])+1))

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = []
for _ in range(M):
    P, Y = map(int, input().split())
    ken[P-1].append(Y)
    shi.append((P, Y))
for k in ken:
    k.sort()
for s in shi:
    print("{:06}{:06}".format(s[0], ken[s[0]-1].index(s[1])+1))

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ken = [[] for _ in range(N)]
shi = []
for _ in range(M):
    P, Y = map(int, input().split())
    ken[P-1].append(Y)
    shi.append((P, Y))
for k in ken:
    k.sort()
for s in shi:
    print("{:06}{:06}".format(s[0], ken[s[0]-1].index(s[1])+1))

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
iPY = [0]*M
res = [0]*M
for i in range(M):
    P, Y = map(int, input().split())
    iPY[i] = (i, P, Y)
iPY.sort(key=itemgetter(2))
iPY.sort(key=itemgetter(1))
j = 1
p = iPY[0][1]
for i, P, Y in iPY:
    if P != p:
        j = 1
        p = P
    res[i] = "{:06}{:06}".format(P, j)
    j += 1
for s in res:
    print(s)