Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = [[] for i in range(n+1)]
pyli = []
for i in range(m):
    p, y = na()
    li[p].append(y)
    pyli.append([p, y])
for yyy in li:
    yyy.sort()
for p, y in pyli:
    i = li[p].index(y)
    shi = str(p)
    num = str(i + 1)
    print(shi.zfill(6) + num.zfill(6))


Fixed submission:
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = []
for i in range(m):
    p, y = na()
    li.append([p,y])
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
for v in dic.values():
    v.sort()
for p, y in li:
    i = dic[p].index(y)
    shi = str(p)
    num = str(i + 1)
    print(shi.zfill(6) + num.zfill(6))


Fixed submission:
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = []
for i in range(m):
    p, y = na()
    li.append([p,y])
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
for v in dic.values():
    v.sort()
for p, y in li:
    i = dic[p].index(y)
    shi = str(p)
    num = str(i + 1)
    print(shi.zfill(6) + num.zfill(6))


Fixed submission:
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = []
for i in range(m):
    p, y = na()
    li.append([p,y])
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
for v in dic.values():
    v.sort()
for p, y in li:
    i = dic[p].index(y)
    shi = str(p)
    num = str(i + 1)
    pad = 6 - len(shi)
    shi = '0' * pad + shi
    pad = 6 - len(num)
    num = '0' * pad + num
    print(shi + num)


Fixed submission:
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = []
for i in range(m):
    p, y = na()
    li.append([p,y])
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
for v in dic.values():
    v.sort()
for p, y in li:
    for i, n in enumerate(dic[p]):
        if n == y:
            shi = str(p)
            num = str(i + 1)
            pad = 6 - len(shi)
            shi = '0' * pad + shi
            pad = 6 - len(num)
            num = '0' * pad + num
            print(shi + num)
            break

Fixed submission:
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = []
for i in range(m):
    p, y = na()
    li.append([p,y])
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
for v in dic.values():
    v.sort()
for p, y in li:
    for i, n in enumerate(dic[p]):
        if n == y:
            shi = str(p)
            num = str(i + 1)
            pad = 6 - len(shi)
            shi = '0' * pad + shi
            pad = 6 - len(num)
            num = '0' * pad + num
            print(shi + num)

Fixed submission:
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = []
for i in range(m):
    p, y = na()
    li.append([p,y])
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
for v in dic.values():
    v.sort()
for p, y in li:
    for i, n in enumerate(dic[p]):
        if n == y:
            shi = str(p)
            num = str(i + 1)
            pad = 6 - len(shi)
            shi = '0' * pad + shi
            pad = 6 - len(num)
            num = '0' * pad + num
            print(shi + num)

Fixed submission:
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))