Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ls = [[int(_) for _ in input().split()] for _ in range(m)]
    
    lss = sorted(ls, key=lambda x: x[1])

    dp = [[] for _ in range(n)] 

    for i in range(m):
        dp[lss[i][0] - 1].append(lss[i][1])
    
    for k in range(m):
        th = dp[ls[k][0] - 1].index(ls[k][1]) + 1
        print(str(ls[k][0]).zfill(6) + str(th).zfill(6))

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ls = [[int(_) for _ in input().split()] for _ in range(m)]
    
    dp = [[] for _ in range(n)] 

    for i in range(m):
        dp[ls[i][0] - 1].append(ls[i][1])
    
    for j in range(n):
        dp[j].sort()

    for k in range(m):
        th = dp[ls[k][0] - 1].index(ls[k][1]) + 1
        print(str(ls[k][0]).zfill(6) + str(th).zfill(6))

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ls = [[int(_) for _ in input().split()] for _ in range(m)]
    
    dp = [[] for _ in range(n)] 

    for i in range(m):
        dp[ls[i][0] - 1].append(ls[i][1])
    
    for j in range(n):
        dp[j].sort()

    for k in range(m):
        th = dp[ls[k][0] - 1].index(ls[k][1]) + 1
        print(str(ls[k][0]).zfill(6) + str(th).zfill(6))

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ls = [[int(_) for _ in input().split()] for _ in range(m)]

dp = [[] for _ in range(n)] 

for i in range(m):
    dp[ls[i][0] - 1].append(ls[i][1])

for j in range(n):
    dp[j].sort()

for k in range(m):
    th = dp[ls[k][0] - 1].index(ls[k][1]) + 1
    print(str(ls[k][0]).zfill(6) + str(th).zfill(6))

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ls = [[int(_) for _ in input().split()] for _ in range(m)]

dp = [[] for _ in range(n)] 

for i in range(m):
    dp[ls[i][0] - 1].append(ls[i][1])

for j in range(n):
    dp[j].sort()

for k in range(m):
    th = dp[ls[k][0] - 1].index(ls[k][1]) + 1
    print(str(ls[k][0]).zfill(6) + str(th).zfill(6))

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ls = [[int(_) for _ in input().split()] for _ in range(m)]

dp = [[] for _ in range(n)] 

for i in range(m):
    dp[ls[i][0] - 1].append(ls[i][1])

for j in range(n):
    dp[j].sort()

for k in range(m):
    th = dp[ls[k][0] - 1].index(ls[k][1]) + 1
    print(str(ls[k][0]).zfill(6) + str(th).zfill(6))

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ls = [[int(_) for _ in input().split()] for _ in range(m)]

dp = [[] for _ in range(n)] 

for i in range(m):
    p = ls[i][0]
    y = ls[i][1]
    dp[p - 1].append(y)

for j in range(n):
    dp[j].sort()

for k in range(m):
    p = ls[k][0]
    y = ls[k][1]
    th = dp[p - 1].index(y) + 1
    print(str(p).zfill(6) + str(th).zfill(6))

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ls = [[int(_) for _ in input().split()] for _ in range(m)]

dp = [[] for _ in range(n)] 

for i in range(m):
    p = ls[i][0]
    y = ls[i][1]
    dp[p - 1].append(y)

for j in range(n):
    dp[j].sort()

for k in range(m):
    p = ls[k][0]
    y = ls[k][1]
    th = dp[p - 1].index(y) + 1
    print(str(p).zfill(6) + str(th).zfill(6))

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()