Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
p = list()
d = dict()
for i in range(M):
    inp = list(map(int, input().split()))
    p.append(inp)
    if inp[0] in d:
        d[inp[0]].append(inp[1])
    else:
        d[inp[0]] = [inp[1]]
for i in d:
    d[i].sort()
for i, j in p:
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))

Fixed submission:
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = list()
d = dict()
for i in range(M):
    inp = map(int, input().split())
    p.append(inp)
    if inp[0] in d:
        d[inp[0]].append(inp[1])
    else:
        d[inp[0]] = [inp[1]]
for i in d:
    d[i].sort()
for i, j in p:
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))

Fixed submission:
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
p = list()
d = dict()
for i in range(M):
    inp = [int(i) for i in input().split()]
    p.append(inp)
    if inp[0] in d:
        d[inp[0]].append(inp[1])
    else:
        d[inp[0]] = [inp[1]]
for i in d:
    d[i] = sorted(d[i])
for i, j in p:
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))

Fixed submission:
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
p = list()
y = list()
d = dict()
for i in range(M):
    inp_p, inp_y = map(int, input().split())
    p.append(inp_p)
    y.append(inp_y)
    if inp_p in d:
        d[inp_p].append(inp_y)
    else:
        d[inp_p] = [inp_y]
# for i in d:
#     d[i] = sorted(d[i])
for i, j in zip(p, y):
    d[i] = sorted(d[i])
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))

Fixed submission:
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
p = list()
y = list()
d = dict()
for i in range(M):
    inp_p, inp_y = map(int, input().split())
    p.append(inp_p)
    y.append(inp_y)
    if inp_p in d:
        d[inp_p].append(inp_y)
    else:
        d[inp_p] = [inp_y]
for i in d:
    d[i] = sorted(d[i])
for i, j in zip(p, y):
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))

Fixed submission:
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = list()
y = list()
d = dict()
for i in range(N):
    inp_p, inp_y = map(int, input().split())
    p.append(inp_p)
    y.append(inp_y)
    if p in d:
        d[p].append(y)
    else:
        d[p] = [y]
for i in d:
    d[i] = sorted(d[i])
for i, j in zip(p, y):
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))

Fixed submission:
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)