Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))


Fixed submission:
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*N
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

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

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))


Fixed submission:
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*N
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    if d < 0:
        print(0)
        exit()
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))


Fixed submission:
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*N
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    b = B[i] // 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))


Fixed submission:
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*N
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = (Y[i]-1)*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    b = B[i] // 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))


Fixed submission:
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*N
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = (Y[i]-1)*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    b = B[i] // 100000
    k = P[d]

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))


Fixed submission:
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*N
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))