Harryxun/stf_run huggingface dataset:
n, m = map(int,input().split())
a = [int(input()) for i in range(m)]
b = [0] * (m+1)
b[0] = a[0] - 1
b[m] = n - a[-1] - 1
if m >= 2:
    for i in range(m-1, 0, -1):
        b[i] = a[i] - a[i-1] - 2
for i in range(m-1):
    if a[i] + 1 == a[i+1]:
        print("0")
        quit()
ans = 1
step = [0] * (n+1)
step[0] = 1
step[1] = 1
for i in range(2, n+1):
    step[i] = (step[i-1] + step[i-2]) % 1000000007
for i in b:
    ans = ans * step[i] % 1000000007
print(ans)  
        

### FIXED CODE ###

import sys
n, m = map(int,input().split())
a = [int(input()) for i in range(m)]
b = [0] * (m+1)
ans = 1
step = [0] * (n+1)
step[0] = 1
step[1] = 1
for i in range(2, n+1):
    step[i] = (step[i-1] + step[i-2]) % 1000000007
if m == 0:
    print(step[n])
    sys.exit()
for i in range(m-1):
    if a[i] + 1 == a[i+1]:
        print("0")
        quit()
if m > 0:
    b[0] = a[0] - 1
    b[m] = n - a[-1] - 1   
if m >= 2:
    for i in range(m-1, 0, -1):
        b[i] = a[i] - a[i-1] - 2
for i in b:
    ans = ans * step[i] % 1000000007
print(ans)
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,n = inpm()
    ans = int(a*n/b) - a*int(n/b)
    if n > b:
        ans = max(ans,int(a*(b-1)/b) - a*int((b-1)/b))
        
    for i in range(1,min(n//b+1)):
        if i*b<=n:
            x = int(a*(b*i-1)/b) - a*int((b*i-1)/b)
            ans = max(ans,x)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    a,b,n = map(int,input().split())
    print(int(a*min((b-1),n)/b) - a*int(min((b-1),n)/b))

if __name__ == "__main__":
    main()
import numpy as np

H, W, K = map(int, input().split())
c = [[] for _ in range(H)]
for i in range(H):
    s = input()
    for j in s:
        if j == '.':
            c[i].append(0)
        else:
            c[i].append(1)

ans = 0
for bit in range(1 << (H+W)):
    red_array = np.full((H, W), False)
    cnt = 0
    for i in range(H+W):
        # print(bin(bit), i, bit>>i, bit>>i == 1, i<H, i-H)
        if (bit>>i)&1 == 1:
            if i < H:
                red_array[i,:] = True
            else:
                red_array[:,i-H] = True
    # print(bin(bit))
    # print(red_array)
    for y in range(H):
        for x in range(W):
            # print(bit, y, x, c[y][x], red_array[y,x],c[y][x] == 1 and not red_array[y, x])
            if c[y][x] == 1 and not red_array[y, x]:
                cnt += 1
    # print(cnt)
    if cnt == K:
        ans += 1
print(ans)

### FIXED CODE ###

import numpy as np

H, W, K = map(int, input().split())
c = [[] for _ in range(H)]
for i in range(H):
    s = input()
    for j in s:
        if j == '.':
            c[i].append(0)
        else:
            c[i].append(1)

ans = 0
for bit in range(1 << (H+W)):
    red_array = np.full((H, W), False)
    cnt = 0
    for i in range(H+W):
        # print(bin(bit), i, bit>>i, bit>>i == 1, i<H, i-H)
        if (bit>>i)&1 == 1:
            if i < H:
                red_array[i,:] = True
            else:
                red_array[:,i-H] = True
    # print(bin(bit))
    # print(red_array)
    for y in range(H):
        for x in range(W):
            # print(bit, y, x, c[y][x], red_array[y,x],c[y][x] == 1 and not red_array[y, x])
            if c[y][x] == 1 and not red_array[y, x]:
                cnt += 1
    # print(cnt)
    if cnt == K:
        ans += 1
print(ans)
from collections import deque
N,ppl,oni = map(int,input().split())
ppl -= 1
oni -= 1
AB = [ []for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    AB[a-1].append(b-1)
    AB[b-1].append(a-1)

def dfs(start):
    dist = [-1 for i in range(N)]
    dist[start] = 0
    que = deque()
    que.append(start)
    while que:
        q = que.popleft()
        for nextr in AB[q]:
            if dist[nextr] == -1:
                dist[nextr] = dist[q] +1
                que.append(nextr)
    return dist
    
if len(AB[ppl]) == 1 and oni in AB[ppl]:
    print(0)
else:
    ppldist = dfs(ppl)
    onidist = dfs(oni)
    maxa = max(onidist)
    for i in range(max(onidist),-1,-1):
        for j in [k for k in range(len(onidist)) if onidist[k] == maxa]:
            if maxa >= ppldist[j]:
                if maxa&ppldist[j] == 1:
                    ans = maxa
                else:
                    ans = maxa-1
    print(ans)

### FIXED CODE ###

from collections import deque
N,ppl,oni = map(int,input().split())
ppl -= 1
oni -= 1
AB = [ []for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    AB[a-1].append(b-1)
    AB[b-1].append(a-1)

def dfs(start):
    dist = [-1 for i in range(N)]
    dist[start] = 0
    que = deque()
    que.append(start)
    while que:
        q = que.popleft()
        for nextr in AB[q]:
            if dist[nextr] == -1:
                dist[nextr] = dist[q] +1
                que.append(nextr)
    return dist
    
if len(AB[ppl]) == 1 and oni in AB[ppl]:
    print(0)
else:
    ppldist = dfs(ppl)
    onidist = dfs(oni)
    maxa = max(onidist)
    ans = 0
    for i in range(N):
        if ppldist[i] < onidist[i]:
            ans = max(ans,onidist[i]-1)
    print(ans)
# 再起の回数？
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
  u, v, w = list(map(int, input().split()))
  u -= 1
  v -= 1
  w = w % 2
  G[u].append([v, w])
  G[v].append([u, w])
  
res = [0] * N
def dfs(u, p, c):
  res[u] = c
  for n in G[u]:
    if n[0] == p:
      continue
    if n[1] == 1:
      dfs(n[0], u, 1-c)
    else:
      dfs(n[0], u, c)
  
def main():
  dfs(0, -1, 1)
  for i in res:
    print(i)
  
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
  u, v, w = list(map(int, input().split()))
  u -= 1
  v -= 1
  w = w % 2
  G[u].append([v, w])
  G[v].append([u, w])
  
res = [-1] * N
"""
def dfs(u, p, c):
  res[u] = c
  for n in G[u]:
    if n[0] == p or res[n[0]] != -1:
      continue
    if n[1] == 1:
      dfs(n[0], u, 1-c)
    else:
      dfs(n[0], u, c)
"""
from collections import deque
q = deque()
# 再帰はメモリ的に厳しい？？
def search(q):
  while q:
    u, p, c = q.popleft()
    if res[u] == -1:
      for n in G[u]:
        if n[0] == p or res[n[0]] != -1:
          continue
        if n[1] == 1:
          q.append((n[0], u, 1-c))
        else:
          q.append((n[0], u, c))
    res[u] = c
  
  
def main():
  q.append((0, -1, 1))
  search(q)
  for i in res:
    print(i)
  
  
if __name__ == "__main__":
  main()
a = int(input())
b = int(input())
if a > b:
    print('GREATER')
elif a < n:
    print('LESS')
else:
    print('EQUAL')

### FIXED CODE ###

a = int(input())
b = int(input())
if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')
r = input()

print(r*r)

### FIXED CODE ###

r = int(input())


print(r*r)
import numpy as np

N, M= (int(i) for i in input().split())  
lr = [[int(i) for i in input().split()] for i in range(M)] 	
a = np.zeros([M,N])
for i in range(M):
	a[i, lr[i][0]-1:lr[i][1]] = 1
b = list(np.all(a == 1, axis=0))
print(sum(b))

### FIXED CODE ###

import numpy as np

N, M= (int(i) for i in input().split())  
lr = [[int(i) for i in input().split()] for i in range(M)] 	
lr = np.array(lr)
l = list(lr[:, 0])
r = list(lr[:, 1])
d = min(r)-max(l)+1
if d>0:
	print(d)
else:
	print(0)
n,k=map(int,input().split())
a=list(int(x) for x in input().split())
a.sort()
s=0
if k <= n:
	print(0)
else:
		s = sum(a[:n-k])
		print(s)

### FIXED CODE ###

h,a=map(int,input().split())
if h % a ==0:
	print(h // a)
else:
	print((h // a ) + 1)
import sys
sys.setrecursionlimit(100000000000)

a,b=map(int,input().split()[:2])

i=1
while True:
    if (a*i -i + 1) >=b:
        print(i)
        exit()
    i+=1

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)

a,b=map(int,input().split()[:2])

i=0
while True:

    if (a*i -i + 1) >=b:
        print(i)
        exit()
    i+=1
def solve():
    x = int(input())
    l = [i**j for i in range(1,x+1) for j in range(1,x+1) if i**j<=x]
    return max(l)
        
if __name__ == '__main__':
    print(solve())

### FIXED CODE ###

def solve():
    l,r = map(int, input().split())
    if r-l<2019:
        arr = [i*j%2019 for i in range(l,r) for j in range(i+1,r+1)]
        return min(arr)
    else:
        return 0


if __name__ == '__main__':
    print(solve())
H , W = map(int,input().split())
S = H * W

if S % 2 = 0:
    print(S//2)
else:
    print(S//2+1)


### FIXED CODE ###

H , W = map(int, input().split())
S = H * W
s = S//2

if H == 1 or W ==1:
    print("1")
elif S % 2 == 0:
    print(s)
else:
    print(s+1)
from collections import Counter
import sys
def zur(z, xx):
    c = 0
    for i in range(z):
        i += 1
        if i not in xx:
            c += 1
        if c == z:
            return c + z

def xxxxx(z, xx):
    if z not in xx:
        return z
    while True:
        z -= 1
        if z == 0:
            print(-1)
            sys.exit()
        if z not in xx:
            return z

i = input()
xs = [int(x) for x in input().strip().split(" ")]
xp = {}

for i, x in enumerate(xs):
    i = i+1
    if x > i:
        print(-1)
        sys.exit()
    if x not in xp:
        xp[x] = list()
    xp[x].append(i)

x = max(xs)
last = len(xs)
xo = []
xx = set()

while True:
    if x == 0:
        break
    nxx = set()
    if x in xp:
        for i in xp[x]:
            xxx = zur(x + last - i, xx)
            xo.append((xxx, x))
            nxx.add(xxx)
        last -= len(xp[x])
    xx = nxx | xx
    x -= 1

for i, x in sorted(xo, key=lambda x:x[0]):
    print(x)


### FIXED CODE ###

from collections import Counter
import sys
def zur(z, xx):
    c = 0
    k = 0
    i = 0
    while True:
        i += 1
        if i in xx:
            c += 1
        else:
            k += 1
        if k == z:
            return z + c

def xxxxx(z, xx):
    if z not in xx:
        return z
    while True:
        z -= 1
        if z == 0:
            print(-1)
            sys.exit()
        if z not in xx:
            return z

def mkxp(xs):
    xp = {}
    for i, x in enumerate(xs):
        i = i+1
        if x > i:
            print(-1)
            sys.exit()
        if x not in xp:
            xp[x] = list()
        xp[x].append(i)
    return xp

i = input()
xs = [int(x) for x in input().strip().split(" ")]
xp = mkxp(xs)


x = max(xs)
xo = []
xx = set()

while True:
    last = len(xs)
    if x == 0:
        break
    nxx = set()
    if x in xp:
        for i in xp[x]:
            xxx = zur(x + last - i, xx)
            xo.append((xxx, x))
            nxx.add(xxx)
        last -= len(xp[x])
    xx = nxx | xx
    xs = [int(i) for i in xs if i != x]
    xp = mkxp(xs)
    x -= 1

for i, x in sorted(xo, key=lambda x:x[0]):
    print(x)
import math

s = input()

N = len(s)
s = "#" + s
possible = 1
if s[-1] == "1":
  possible = 0
for i in range(1,math.floor(N/2)):
  if s[i] != s[N - i]:
    possible = 0

if not possible:
  print(-1)
else:
  destination = [1] * (N+1)
  root = 2
  for i in range(math.floor(N/2), -1, -1):
    if s[i] == "1":
      for j in range(1, i):
        destination[root + j] = root
      root += 1
for i in range(2,N+1):
  print(i, destination[i])

### FIXED CODE ###

import math

s = input()

N = len(s)
s = "#" + s
possible = 1
if s[-1] == "1" or s[1] == "0":
  possible = 0
for i in range(1,math.floor(N/2)):
  if s[i] != s[N - i]:
    possible = 0

if not possible:
  print(-1)
elif N == 2:
  if s[1] == "1" and s[2] == "0":
    print(1, 2)
  else:
    print(-1)
elif N == 3:
  if s[1] == "1" and s[2] == "1":
    print(1,2)
    print(2,3)
  else:
    print(-1)
else:
  destination = [1] * (N+1)
  dest_change = [0] * (N+1)
  root = 2
  max_bit = math.floor(N/2)
  for i in range(max_bit, -1, -1):
    if s[i] == "1":
      #destination = destination[:root+1] + [root]*(i-1) + destination[root+i:]
      dest_change[root + 1] = dest_change[root + 1] + 1
      dest_change[root + i] = dest_change[root + i] - 1
      root += 1
  for i in range(1,N+1):
    destination[i] = destination[i - 1] + dest_change[i]
  for i in range(2,N+1):
    print(i, destination[i])
import math

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()


dict = {}

for i in range(len(D)):
    if D[i] not in dict:
        dict[D[i]] = 1
    else:
        dict[D[i]] += 1

for key in dict:
    if key == 0:
        break
    if dict[key] == 0:
        print(0)
        exit()
sum = 1
n = 0

#dict = list(sorted(dict.items(), key=lambda x:x[0]))
dict_dm = sorted(dict)
#print(dict)
#print(dict_dm)

for i in range(len(dict_dm) + 1):
    if i == 1:
        #print("check2")
        n = dict[i]
    elif i >=1:
        #print("check1")
        sum *= n**dict[i]
        n = dict[i]

print(sum%998244353)

### FIXED CODE ###

import math

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

dict = {}

for i in range(len(D)):
    if D[i] not in dict:
        dict[D[i]] = 1
    else:
        dict[D[i]] += 1

for i in range(max(D)):
    if i not in dict:
        dict[i] = 0
    
for key in dict:
    if key == 0:
        if dict[key] != 1:
            print(0)
            exit()       
    if dict[key] == 0:
        print(0)
        exit()
sum = 1
n = 0

#dict = list(sorted(dict.items(), key=lambda x:x[0]))
dict_dm = sorted(dict)
#print(dict)
#print(dict_dm)
flg = 0
for i in range(len(dict_dm)):
    if i == 1:
        #print("check2")
        n = dict[i]
    elif i >=1:
        #print("check1")
        sum = (sum * n**dict[i])%998244353
        n = dict[i]

print(sum%998244353)
a,b=map(int,input().split())
ans,num=0,1:
while num<b:
    num-=1
    num+=a
    ans+=1
print(ans)

### FIXED CODE ###

import math 
a,b=map(int,input().split())
print(math.ceil((b-1)/(a-1)))
#ref : https://atcoder.jp/contests/abc128/submissions/5694292
#工事を座標順に処理，工事にぶつかる人をにぶたん
#すでに更新済みだったら更新しない．-> jumpで管理
from bisect import bisect_left
N, Q = map(int, input().split())
consts = []
for _ in range(N):
    s,t,x = map(int, input().split())
    consts.append((x,s,t))
const.sort()
D=[int(input()) for _ in range(Q)]
ans=[-1]*Q
jump=[-1]*Q
for x,s,t in consts:
    left=bisect_left(D,s-x)
    right=bisect_left(D,t-x)
    while left<right:
        if jump[left]==-1:
            ans[left]=x
            jump[left]=right
            left += 1
        else:
            left=jump[left]
print(*ans, sep='\n')

### FIXED CODE ###

from bisect import bisect_left
N, Q = map(int, input().split())
consts = []
for _ in range(N):
    s,t,x = map(int, input().split())
    consts.append((x,s,t))
consts.sort()
D=[int(input()) for _ in range(Q)]
ans=[-1]*Q
jump=[-1]*Q
for x,s,t in consts:
    left=bisect_left(D,s-x)
    right=bisect_left(D,t-x)
    while left<right:
        if jump[left]==-1:
            ans[left]=x
            jump[left]=right
            left += 1
        else:
            left=jump[left]
print(*ans, sep='\n')
import sys
sys.setrecursionlimit(3*10**5)

n = int(input())
edge = [tuple(map(int, input().split())) for _ in range(n-1)]
mod = 10 ** 9 + 7
def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y

def moddiv(a, b):
    _, inv, _ = extGCD(b, mod)
    return (a * inv) % mod

N = 10 ** 5 + 10
fact = [0] * (N)
fact[0] = 1
for i in range(1, N):
    fact[i] = (fact[i-1] * i) % mod

def comb(a, b):
    return moddiv(moddiv(fact[a], fact[a-b]), fact[b])

connect = [set() for _ in range(n)]
for a, b in edge:
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

d = [{} for _ in range(n)]

def dfs(v, p):
    if p in d[v]:
        return d[v][p]
    num, count = 0, 1
    for next in connect[v]:
        if next != p:
            i, c = dfs(next, v)
            num += i
            count *= c
            count %= mod
            count *= comb(num, i)
            count %= mod
    num += 1
    d[v][p] = num, count
    return num, count

for i in range(n):
    dfs(i, -1)
    print(d[i][-1][1])

### FIXED CODE ###

s = input()

if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
class Node:
    def __init__(self, i):
        self.index = i
        self.val = -1
        self.nodes = []
        self.link = 0

    def __lt__(self, other):
        # self < other
        return self.link < other.link

def width_search(node):
    if node.val == -1:
        node.val = c.pop(0)
        for child in sorted(node.nodes):
            width_search(child)

N = int(input())
if N == 1:
    print(0)
else:
    nodes = [Node(i) for i in range(N)]

    for i in range(N-1):
        a, b = map(int, input().split())
        node_a = nodes[a-1]
        node_b = nodes[b-1]
        node_b.nodes.append(node_a)
        node_b.link += 1
        node_a.nodes.append(node_b)
        node_a.link += 1

    c = list(map(int, input().split()))
    c = sorted(c, reverse=True)

    max_c = 0
    sum_c = 0
    for tmp in c:
        sum_c += tmp
        max_c = max(max_c, tmp)

    width_search(max(nodes))

    print(sum_c - max_c)
    for i in range(N-1):
        print(nodes[i].val, end=" ")
    print(nodes[-1].val)


### FIXED CODE ###

from collections import deque

class Node:
    def __init__(self):
        self.val = -1
        self.link = []

def main():
    N = int(input())
    nodes = [Node() for i in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1; b -= 1;
        nodes[a].link.append(nodes[b])
        nodes[b].link.append(nodes[a])
    c = list(map(int, input().split()))
    c = sorted(c, reverse=True)
    count = 0
    q = deque()
    q.append(nodes[0])
    while len(q) > 0:
        node = q.popleft()
        node.val = c[count]
        count += 1
        for next in node.link:
            if next.val == -1:
                q.append(next)
    print(sum(c) - c[0])
    for i in range(N):
        print(nodes[i].val, end="")
        if i != N-1:
            print(" ",end="")
        else:
            print()

if __name__ == "__main__":
    main()
n = int(input())
p = map(int,input().split())

large_small = -1
ans = 2
for i in range(n-1):
    if p[i] > p[i+1]:
        if large_small == 1:
            ans += 1
        large_small = 1
    elif p[i] < p[i+1]:
        if large_small == -1:
            ans += 1
        large_small = -1
    else:
        large_small = 0

print(ans)


### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))

large_small = 2
ans = 0
for i in range(n-1):
    if p[i] > p[i+1]:
        if large_small == 1:
            ans += 1
        large_small = 1
    elif p[i] < p[i+1]:
        if large_small == -1:
            ans += 1
        large_small = -1
    else:
        large_small = 0

print(ans)
N = int(input())
A = list(map(int. input().split())
for i in range(1,N+1):
    print(A.count(i))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in A:
    B[i-1] += 1
for j in range(N):
    print(B[j])
import numpy as np
import sys

N = int(input())
As = [list(map(int,input().split())) for i in range(N)]
As = np.array(As)-1


current_waitings = As[:,0]
game_counter = np.zeros(N).astype('int')

day = 0
completed_players = []
day_player = []
for x in range(N*(N+1)//2):
    day_player = []
    for i,e1 in enumerate(current_waitings):
        if i in completed_players:
            continue
        if current_waitings[e1] == i and e1 not in day_player and i not in day_player:
            day_player.append(i)
            day_player.append(e1)
            if game_counter[i] == N-2:
                completed_players.append(i)
            if game_counter[i] <= N-3:
                game_counter[i] += 1
            if game_counter[e1] == N-2:
                completed_players.append(e1)
            if game_counter[e1] <= N-3:
                game_counter[e1] += 1
            current_waitings[i] = As[i][game_counter[i]]
            current_waitings[e1] = As[e1][game_counter[e1]]
        if len(completed_players) == N:
            print(day+1)
            sys.exit()
    day += 1
print(-1)



### FIXED CODE ###

from collections import deque
def solve():
    n = int(input())
    a = []
    for i in range(n):
        ai = [int(j)-1 for j in input().split()]
        a.append(deque(ai))
    d = set()
    q = deque()
    for i in range(n):
        ai = a[i].popleft()
        if i < ai:
            q.append((i, ai))
        else:
            q.append((ai, i))
    ans = 0
    while q:
        ans += 1
        nxt_q = deque()
        while q:
            i, ai = q.pop()
            if (i, ai) in d:
                if a[i]:
                    ni = a[i].popleft()
                    if i < ni:
                        nxt_q.append((i, ni))
                    else:
                        nxt_q.append((ni, i))
                if a[ai]:
                    ni = a[ai].popleft()
                    if ai < ni:
                        nxt_q.append((ai, ni))
                    else:
                        nxt_q.append((ni, ai))
            else:
                d.add((i, ai))
        q = nxt_q
    if any(i for i in a):
        ans = -1
    print(ans)

solve()
import math
import numpy as np
n=input()
list=list(map(int,input().split()))
list=np.array(list,int)

p=math.log10(list)
p=p.sum()
if p>=18:
  print(-1)
else:
  print(np.prod(list))

### FIXED CODE ###

n=input()
list=list(map(int,input().split()))

flg=True
if 0 in list:
  print(0)
  flg=False
else:
  prod=1
  for a in list:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      flg=False
      break
if flg:
  print(prod)
def inlt():
    return(list(map(int,input().split())))
  
i <- inlt()

D <- i[0]
T <- i[1]
S <- i[2]

if D > S*T:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))
  
i = inlt()
D = i[0]
T = i[1]
S = i[2]
 
if D/T > S:
  print("No")
else:
  print("Yes")
a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

[print(c[2]) for c in ans[0]]


### FIXED CODE ###

n = int(input())


def f(n):
    n[1] = int(n[1])
    return n


a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

for c in ans:
    for d in c:
        print(d[2])
I=lambda:list(map(int,input().split()));n,m=I();l=[I()+[i]for i in range(M)];c=[0]*-~N;a=[0]*M
for p,y,i in sorted(l,key=lambda x:x[1]):c[p]+=1;a[i]='%06d'%p+'%06d'%c[p]
for t in a:print(t)

### FIXED CODE ###

I=lambda:map(int,input().split())
n,m=I()
l=[[]for _ in range(n+1)]
for i in range(m):
  p,y=I()
  l[p].append([y,i])
a=[]
for p in range(1,n+1):
  l[p].sort()
  for i,t in enumerate(l[p]):
    a.append([t[1],'%06d'%p+'%06d'%-~i])
a.sort()
for t in a:
  print(t[1])