Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
py = [[int(i) for i in input().split()] for _ in range(m)]
py_ = [[] for _ in range(m)]
for pi, yi in py:
    py_[pi-1].append(yi)
for i in range(m):
    py_[i].sort()
for pi, yi in py:
    print(str(pi).zfill(6) + str(py_[pi-1].index(yi) + 1).zfill(6))

Fixed submission:
import bisect as bis
n, m = map(int, input().split())
idx = lambda x: x-1
p, y = [], []
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i, j in zip(p, y):
    val[idx(i)].append(j)
for i in range(n):
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])
    print(str(v).zfill(6) + str(id).zfill(6))

Buggy python submission (verdict: Runtime Error):
n, m = (int(x) for x in input().split())
d = [[] for _ in range(m)]
py = []
for i in range(m):
    py.append([int(x) for x in input().split()])
    d[py[i][0]-1].append(py[i][1])
for li in d:
    li.sort()
for li in py:
    print(str(li[0]).zfill(6) + str(d[li[0]-1].index(li[1])+1).zfill(6))

Fixed submission:
import bisect as bis
n, m = map(int, input().split())
idx = lambda x: x-1
p, y = [], []
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i, j in zip(p, y):
    val[idx(i)].append(j)
for i in range(n):
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])
    print(str(v).zfill(6) + str(id).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = (int(x) for x in input().split())
l = []
d = {}
ds = []
for _ in range(m):
    l.append([int(x) for x in input().split()])
for li in l:
    k = str(li[0])
    if k not in ds:
        d[k] = [li[1]]
        ds.append(k)
    else:
        d[k].append(li[1])
for key in ds:
    d[key].sort()
for li in l:
    print(str(li[0]).zfill(6) + str(d[str(li[0])].index(li[1]) + 1).zfill(6))

Fixed submission:
import bisect as bis
n, m = map(int, input().split())
idx = lambda x: x-1
p, y = [], []
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i, j in zip(p, y):
    val[idx(i)].append(j)
for i in range(n):
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])
    print(str(v).zfill(6) + str(id).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = (int(x) for x in input().split())
l = []
d = {}
ds = []
for _ in range(m):
    l.append([int(x) for x in input().split()])
for i in range(m):
    k = str(l[i][0])
    if k not in ds:
        d[k] = [l[i][1]]
        ds.append(k)
    else:
        d[k].append(l[i][1])
for key in ds:
    d[key].sort()
for li in l:
    print(str(li[0]).zfill(6) + str(d[str(li[0])].index(li[1]) + 1).zfill(6))

Fixed submission:
import bisect as bis
n, m = map(int, input().split())
idx = lambda x: x-1
p, y = [], []
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i, j in zip(p, y):
    val[idx(i)].append(j)
for i in range(n):
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])
    print(str(v).zfill(6) + str(id).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = (int(x) for x in input().split())
l = []
d = {}
for _ in range(m):
    l.append([int(x) for x in input().split()])
for i in range(m):
    k = str(l[i][0])
    if k not in d.keys():
        d[k] = [l[i][1]]
    else:
        d[k].append(l[i][1])
for key in d.keys():
    d[key].sort()
for li in l:
    print(str(li[0]).zfill(6) + str(d[str(li[0])].index(li[1]) + 1).zfill(6))

Fixed submission:
import bisect as bis
n, m = map(int, input().split())
idx = lambda x: x-1
p, y = [], []
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i, j in zip(p, y):
    val[idx(i)].append(j)
for i in range(n):
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])
    print(str(v).zfill(6) + str(id).zfill(6))