Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
F = [list(map(int, (input().split()))) for i in range(M)]
tmp = [[] for i in range(N)]

for i in range(M):
    tmp[F[i][0]-1].append(F[i][1])
    
for i in range(N):
    tmp[i].sort()
    
for i in range(M):
    X = str(tmp[F[i][0]-1].index(F[i][1])+1)
    print(('0'*(6-len(str(F[i][0]))) + str(F[i][0])) + '0'*(6-len(X)) + X)

Fixed submission:
N, M = map(int, input().split())
#tmp = [[] for i in range(N)]
tmp = []
res = ['' for i in range(M)]
count = [1 for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    tmp.append([A,B,i])

tmp.sort(key=lambda tmp: tmp[1])

for i in range(M):
    res[tmp[i][2]] += '0'*(6-len(str(tmp[i][0]))) + str(tmp[i][0]) + '0'*(6-len(str(count[tmp[i][0]]))) + str(count[tmp[i][0]])
    count[tmp[i][0]] += 1

for i in range(M):
    print(res[i])

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
tmp = [[] for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    tmp[A-1].append(B)

for i in range(N):
    tmp[i].sort()
    
for i in range(M):
    X = tmp[F[i][0]-1].index(F[i][1])+1
    print(('0'*(6-len(str(F[i][0]))) + str(F[i][0])) + '0'*(6-len(str(X))) + str(X))

Fixed submission:
N, M = map(int, input().split())
#tmp = [[] for i in range(N)]
tmp = []
res = ['' for i in range(M)]
count = [1 for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    tmp.append([A,B,i])

tmp.sort(key=lambda tmp: tmp[1])

for i in range(M):
    res[tmp[i][2]] += '0'*(6-len(str(tmp[i][0]))) + str(tmp[i][0]) + '0'*(6-len(str(count[tmp[i][0]]))) + str(count[tmp[i][0]])
    count[tmp[i][0]] += 1

for i in range(M):
    print(res[i])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
F = [list(map(int, (input().split()))) for i in range(M)]
tmp = [[] for i in range(N)]

for i in range(M):
    tmp[F[i][0]-1].append(F[i][1])

for i in range(N):
    tmp[i].sort()
    
for i in range(M):
    X = tmp[F[i][0]-1].index(F[i][1])+1
    print(('0'*(6-len(str(F[i][0]))) + str(F[i][0])) + '0'*(6-len(str(X))) + str(X))

Fixed submission:
N, M = map(int, input().split())
#tmp = [[] for i in range(N)]
tmp = []
res = ['' for i in range(M)]
count = [1 for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    tmp.append([A,B,i])

tmp.sort(key=lambda tmp: tmp[1])

for i in range(M):
    res[tmp[i][2]] += '0'*(6-len(str(tmp[i][0]))) + str(tmp[i][0]) + '0'*(6-len(str(count[tmp[i][0]]))) + str(count[tmp[i][0]])
    count[tmp[i][0]] += 1

for i in range(M):
    print(res[i])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
F = [list(map(int, (input().split()))) for i in range(M)]
tmp = [[] for i in range(N)]

for i in range(M):
    tmp[F[i][0]-1].append(F[i][1])

for i in range(N):
    tmp[i].sort()
    
for i in range(M):
    print(('0'*(6-len(str(F[i][0]))) + str(F[i][0])) + '0'*(6-len(str(tmp[F[i][0]-1].index(F[i][1])+1))) + str(tmp[F[i][0]-1].index(F[i][1])+1))

Fixed submission:
N, M = map(int, input().split())
#tmp = [[] for i in range(N)]
tmp = []
res = ['' for i in range(M)]
count = [1 for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    tmp.append([A,B,i])

tmp.sort(key=lambda tmp: tmp[1])

for i in range(M):
    res[tmp[i][2]] += '0'*(6-len(str(tmp[i][0]))) + str(tmp[i][0]) + '0'*(6-len(str(count[tmp[i][0]]))) + str(count[tmp[i][0]])
    count[tmp[i][0]] += 1

for i in range(M):
    print(res[i])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
F = [list(map(int, (input().split()))) for i in range(M)]
tmp = [[] for i in range(N)]

for i in range(M):
    tmp[F[i][0]-1].append(F[i][1])

for i in range(N):
    tmp[i].sort()
    
for i in range(M):
    print(('0'*(6-len(str(F[i][0]))) + str(F[i][0])) + '0'*(6-len(str(tmp[F[i][0]-1].index(F[i][1])+1))) + str(tmp[F[i][0]-1].index(F[i][1])+1))

Fixed submission:
N, M = map(int, input().split())
#tmp = [[] for i in range(N)]
tmp = []
res = ['' for i in range(M)]
count = [1 for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    tmp.append([A,B,i])

tmp.sort(key=lambda tmp: tmp[1])

for i in range(M):
    res[tmp[i][2]] += '0'*(6-len(str(tmp[i][0]))) + str(tmp[i][0]) + '0'*(6-len(str(count[tmp[i][0]]))) + str(count[tmp[i][0]])
    count[tmp[i][0]] += 1

for i in range(M):
    print(res[i])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
F = [list(map(int, (input().split()))) for i in range(M)]
tmp = [[] for i in range(N)]

for i in range(M):
    tmp[F[i][0]-1].append(F[i][1])

for i in range(N):
    tmp[i].sort()
    
for i in range(M):
    print(('0'*(6-len(str(F[i][0]))) + str(F[i][0])) + '0'*(6-len(str(tmp[F[i][0]-1].index(F[i][1])+1))) + str(tmp[F[i][0]-1].index(F[i][1])+1))

Fixed submission:
N, M = map(int, input().split())
#tmp = [[] for i in range(N)]
tmp = []
res = ['' for i in range(M)]
count = [1 for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    tmp.append([A,B,i])

tmp.sort(key=lambda tmp: tmp[1])

for i in range(M):
    res[tmp[i][2]] += '0'*(6-len(str(tmp[i][0]))) + str(tmp[i][0]) + '0'*(6-len(str(count[tmp[i][0]]))) + str(count[tmp[i][0]])
    count[tmp[i][0]] += 1

for i in range(M):
    print(res[i])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
F = [list(map(int, (input().split()))) for i in range(M)]
tmp = [[] for i in range(N)]

for i in range(M):
    tmp[F[i][0]-1].append(F[i][1])

for i in range(N):
    tmp[i].sort()
    
for i in range(M):
    print(('0'*(6-len(str(F[i][0]))) + str(F[i][0])) + '0'*(6-len(str(tmp[F[i][0]-1].index(F[i][1])+1))) + str(tmp[F[i][0]-1].index(F[i][1])+1))

Fixed submission:
N, M = map(int, input().split())
#tmp = [[] for i in range(N)]
tmp = []
res = ['' for i in range(M)]
count = [1 for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    tmp.append([A,B,i])

tmp.sort(key=lambda tmp: tmp[1])

for i in range(M):
    res[tmp[i][2]] += '0'*(6-len(str(tmp[i][0]))) + str(tmp[i][0]) + '0'*(6-len(str(count[tmp[i][0]]))) + str(count[tmp[i][0]])
    count[tmp[i][0]] += 1

for i in range(M):
    print(res[i])