Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N=int(input())
ans=0

for i in range(1,10**6):
  for j in range(1,(10**6)//i+1):
    if N > i*j:
      ans += 1

print(ans)

### FIXED CODE ###

N=int(input())
ans=0

for i in range(1,10**6):
  for j in range(i,10**6//i+1):
    if N > i*j:
      if i==j:
        ans += 1
      else:
        ans += 2

print(ans)
### BUGGY CODE ###

import numpy as np
n, m = map(int, input().split())


card_list = np.zeros(n)

for i in range(m):
    l, r = map(int, input().split())
    card_list[l-1:r] += 1

print(np.count_nonzero(card_list == m))




### FIXED CODE ###

import numpy as np
n, m = map(int, input().split())


#card_list = np.zeros(n)

under = 1
top = n

for i in range(m):
    l, r = map(int, input().split())
    if under < l:
        under = l
    if top > r:
        top = r

#print(under, top)
if top-under+1 < 0:
    print(0)
else:
    print(top-under+1)
### BUGGY CODE ###

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

num=0
for i in range(n):
    count=0
    for j in range (n):
        if a[i]%a[j]==0:
            count+=1
        
    if count==1:
            num+=1

print(num)

### FIXED CODE ###

import collections

n=int(input())
a=list(map(int,input().split()))
M=max(a)

c=[0 for _ in range(M+1)]

for i in a:
    if c[i] != 0:
        c[i] = 2
        continue 
    for j in range(i,M+1,i):
        c[j]+=1

answer = 0

for i in a:
    if c[i] == 1:
        answer+=1


print(answer)
### BUGGY CODE ###

import math

A, B, N = [int(x) for x in input().split()]
val = 0

for i in range(min(B, N+1)):
    a = math.floor(float(A*i)/B) - A * math.floor(float(i)/B)
    if a > val:
        val = a

print(val)





### FIXED CODE ###

import math

A, B, N = [int(x) for x in input().split()]
count = min(B-1, N)
a = math.floor(float(A*count)/B) - A * math.floor(float(count)/B)
print(a)
### BUGGY CODE ###

N = int(input())
X = [int(x) for x in input().split()]

X2 = sorted(X)

for i in range(0, N):
    idx = X2.index(X[i])
    if idx < N // 2:
        print(X2[N // 2])
    else:
        print(X2[N // 2 - 1])


### FIXED CODE ###

import bisect

N = int(input())
X = [int(x) for x in input().split()]

X2 = sorted(X)

for i in range(0, N):
    # idx = X2.index(X[i])
    idx = bisect.bisect_left(X2, X[i])
    if idx < N // 2:
        print(X2[N // 2])
    else:
        print(X2[N // 2 - 1])
### BUGGY CODE ###

import numpy as np

num = input()
num = int(num)

str = input()
list_in = str.split()
list_in = [int(x) for x in list_in]

count_arr = np.zeros((num+1), dtype=np.int32)

for item in list_in:
    count_arr[int(item)] += 1

sum = 0
for i in range(len(count_arr)):
    tmp = count_arr[i]
    tmp = (tmp * (tmp -1))//2
    sum += tmp

for item in list_in:
    tmp = count_arr[item] - 1
    result = (sum - tmp)
    print(result)


### FIXED CODE ###

import numpy as np

num = input()
num = int(num)

str = input()
list_in = list(map(int, str.split()))

count_arr = [0]*num

for item in list_in:
    count_arr[item-1] += 1

sum = 0
for i in range(num):
    tmp = count_arr[i-1]
    tmp = (tmp * (tmp -1))//2
    sum += tmp

for item in list_in:
    tmp = count_arr[item-1]
    result = sum - (tmp - 1)
    print(result)
### BUGGY CODE ###

import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
a = [I() for _ in range(M)]
dp = [0]*(N+1) #1_indexed
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2,N+1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = dp[i-1]+dp[i-2]
    dp[i] %= 10**9+7
print(dp[-1])


### FIXED CODE ###

def main(N,M,a):
    dp = [-1]*N
    dp[0] = 1
    if N != 1:
        dp[1] = 2
    for i in a:
        if i == 1:
            dp[0] = 0
            dp[1] = 1
        else:
            dp[i-1] = 0
    for i in range(2,N):
        if dp[i] != 0:
            dp[i] = dp[i-1] + dp[i-2]
    return dp[-1]
N,M = map(int, input().split())
a = list(int(input()) for i in range(M))

print(main(N,M,a) % 1000000007)
### BUGGY CODE ###

import numpy as np

N, M, K = map(int, input().split())

LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
for _ in range(M):
    L, R = map(int, input().split())
    LR[L, R] += 1

np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)

P, Q = np.array([list(map(int, input().split())) for _ in range(K)], dtype=np.int32).T

P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep='\n')


### FIXED CODE ###

N, M, Q = map(int, input().split())

train = [[0 for _ in range(N+1)] for _ in range(N+1)]

for _ in range(M) :
    L, R = map(int, input().split())
    train[L][R] += 1

que = []
for _ in range(Q) :
    p, q = map(int, input().split())
    que.append((p, q))

# 累積和
S = [[0 for _ in range(N+1)] for _ in range(N+1)]  # ゼロパディング

for l in range(1, N+1) :
    for r in range(1, N+1) :
        S[l][r] = S[l-1][r] + S[l][r-1] - S[l-1][r-1] + train[l][r]

for p, q in que :
    ans = S[q][q] - S[p-1][q] - S[q][p-1] + S[p-1][p-1]
    print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 8)


def dp(i, j, memo={}):
    if (i, j) in memo:
        return memo[i, j]
    elif i < 0 or j < 0:
        return 0
    elif i == 0 and j == 0:
        return 1
    res = dp(i - 1, j - 2, memo) + dp(i - 2, j - 1, memo)
    memo[i, j] = res
    return res


x, y = map(int, input().split())
print(dp(x, y) % (10 ** 9 + 7))

### FIXED CODE ###

import math
MOD = 1000000000+7
X, Y = map(int, input().split())
 
if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0) or (2*Y-X) < 0 or (2*X-Y) < 0:
    print(0)
elif 2 *Y == X or 2 * X == Y:
    print(1)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]
 
    fac_list[0] = 1
    for i in range(1, x+y+2):
        fac_list[i] = i * fac_list[i-1] % MOD
 
    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, 0, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD
 
    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)
### BUGGY CODE ###

n, w = map(int, input().split())
dp = [-1 for _ in range(w + 1)]
dp[0] = 0
ans = 0
for w, v in (map(int, input().split()) for _ in range(n)):
    for i in range(len(dp) - 1, w - 1, -1):
        if dp[i - w] >= 0:
            dp[i] = max(dp[i - w] + v, v, dp[i])
            ans = max(ans, dp[i])
print(ans)

### FIXED CODE ###

n, w = map(int, input().split())
dp = [-1 for _ in range(w + 1)]
dp[0] = 0
ans = 0
for w, v in (map(int, input().split()) for _ in range(n)):
    for i in range(len(dp) - 1, w - 1, -1):
        if dp[i - w] >= 0:
            dp[i] = max(dp[i - w] + v, v, dp[i])
            ans = max(ans, dp[i])
print(ans)
### BUGGY CODE ###

N = int(input())
water = [int(x) for x in input().split()]
rain = [0]*N
sum = 0
for i in water:
    sum += i

for k in range(N):
    sa = 0
    numofloop = 0
    ite = k + 1
    if (ite >= N):
        ite -= N
    while (numofloop < (N - 1) / 2):
        sa += water[ite]
        ite += 2
        if (ite >= N):
            ite -= N
        numofloop += 1
    sa *= 2
    rain[k] = sum - sa

print(' '.join(map(str, rain)))


### FIXED CODE ###

# editorial を参考にした
N = int(input())
water = [int(x) for x in input().split()]
rain = [0]*N
sum = 0

for i in water:
    sum += i


sa = 0
numofloop = 0
ite = 1
while (numofloop < (N - 1) / 2):
    sa += water[ite]
    ite += 2
    if (ite >= N):
        ite -= N
    numofloop += 1
sa *= 2
rain[0] = sum - sa

for k in range(1, N):
    rain[k] = 2*water[k-1]-rain[k-1]

print(' '.join(map(str, rain)))
### BUGGY CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
from collections import OrderedDict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right


class EndLoop(Exception):
    pass


def solve():
    while 1:
        try:
            N, M = list(map(int, input().split(" ")))
            Deque1 = deque()
            DequeN = deque()
            edges_1 = [None] * N
            edges_N = [None] * N
            Deque1.extend(edges_1)
            DequeN.extend(edges_N)

            for _ in range(M):
                a, b = list(map(int, input().split(" ")))
                if a == 1:
                    Deque1[b - 1] = True
                elif b == 1:
                    Deque1[a - 1] = True
                elif a == N:
                    DequeN[b - 1] = True
                elif b == N:
                    DequeN[a - 1] = True
                else:
                    pass

            for i in range(N):
                if Deque1[i] == True and DequeN[i] == True:
                    print("POSSIBLE")
                    raise EndLoop

            print("IMPOSSIBLE")
            break
        except:
            break


solve()

### FIXED CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-
from collections import deque


class EndLoop(Exception):
    pass


def solve():
    while 1:
        try:
            N, M = list(map(int, input().split(" ")))
            Deque1 = deque()
            DequeN = deque()
            edges_1 = [False] * N
            edges_N = [False] * N
            Deque1.extend(edges_1)
            DequeN.extend(edges_N)

            for _ in range(M):
                a, b = list(map(int, input().split(" ")))
                if a == 1:
                    Deque1[b - 1] = True
                elif b == 1:
                    Deque1[a - 1] = True
                elif a == N:
                    DequeN[b - 1] = True
                elif b == N:
                    DequeN[a - 1] = True
                else:
                    pass

            for i in range(N):
                if Deque1[i] == True and DequeN[i] == True:
                    print("POSSIBLE")
                    raise EndLoop

            print("IMPOSSIBLE")
            break
        except:
            break


solve()
### BUGGY CODE ###

x = int(input())
def make_divisors(n):
    divisors = [0]
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

flag = 0
a_s = 0
if x == 1:
  print(1, 0)
else:
  l = make_divisors(x)
  for i in range(x+1):
    if 2*(i**5) >= x:
      a_s = i
      break
  for a in range(a_s, x+1):
    if flag == 1:
      break
    for b_a in l:
      if b_a <= a:
        b = a - b_a
        if a**5 - b**5 == x:
          print(a, b)
          flag += 1
          break
        elif a**5 + b**5 == x:
          print(a, -1*b)
          flag += 1
          break
      else:
        continue

### FIXED CODE ###

x = int(input())
def make_divisors(n):
    divisors = [0]
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    return divisors

flag = 0
a_s = 0
if x == 1:
  print(1, 0)
else:
  l = make_divisors(x)
  for a in range(a_s, x+1):
    if flag == 1:
      break
    for b_a in l:
      if b_a <= a:
        b = a - b_a
        if a**5 - b**5 == x or a**5 + b**5 == x:
          flag += 1
          print(a, b)
          break
      if b_a > a:
        b = b_a - a
        if a**5 + b**5 == x:
          flag += 1
          print(a, -b)
          break
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
L = [A[0]]
for i in range(1,N):
  L.append(L[i-1]+A[i])
k = 0
for i in range(N):
  for j in range(i+1,N):
    if (L[i] - L[j] == 0):
        k += 1
p = L.count(0)
print(k+p)

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
S = [0]
c = 0
for i in range(N):
  c = S[i] + L[i]
  S.append(c)
S.sort()
S.append(S[N]+1)
k = 0
p = 1
ans = 0
while k <= N:
  if S[k] == S[k+1]:
    p += 1
    k += 1
  else:
    ans += p*(p-1)//2
    p = 1
    k += 1
print(ans)
### BUGGY CODE ###

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

ans = 0
m = 1
for i in a:
    m *= i

while True:
    if m % 2 == 0:
        ans += 1
        m //= 2
    else:
        break

print(ans)


### FIXED CODE ###

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

ans = 0
for i in a:
    count = 0
    while True:
        if i % 2**(count+1) == 0:
            count += 1
        else:
            ans += count
            break

print(ans)
### BUGGY CODE ###

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

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    ans += a[i] * a[j]
    
ans %= 10 ** 9 + 7
print(ans)

### FIXED CODE ###

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

sum = sum(a) - a[0]

ans = 0
for i in range(n):
  ans += a[i] * sum
  if (i == n-1):
    break
  else:
  	sum -= a[i+1]
  
ans %= 10 ** 9 + 7  
print(ans)
### BUGGY CODE ###

N = int(input())
li = [input() for i in range(N)]
li.sort()

key = set(li)
c = [0]*len(key)
ind = 0
ans = [[] for _ in range(len(key))]
for i in key:
    ans[ind] = [li.count(i), i]
    ind += 1

ans.sort(reverse=True)
p = ans[0][0]
q = []
for i in range(len(ans)):
    if ans[i][0] == p:
        q.append(ans[i][1])
q.sort()
[print(i) for i in q]


### FIXED CODE ###

import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

N = int(input())
li = [input() for i in range(N)]
li.sort()

key = set(li)
c = [0]*len(key)
ind = 0
ans = [[] for _ in range(len(key))]
for i in key:
    p = bisect_left(li,i)
    q = bisect_right(li,i)
    ans[ind] = [q-p, i]
    ind += 1

ans.sort(reverse=True)
p = ans[0][0]
q = []
for i in range(len(ans)):
    if ans[i][0] == p:
        q.append(ans[i][1])
q.sort()
[print(i,end='') for i in q]
### BUGGY CODE ###

s = input()
q = int(input())
first = 1

for i in range(q):
    t = input().split()
    if int(t[0]) == 1:
        first *= -1
    else:
        f = int(t[1])
        c = t[2]
        
        if first == 1:
            if f == 1:
                s = c + s
            elif f == 2:
                s = s + c
        else:
            if f == 1:
                s = s + c
            elif f == 2:
                s = c + s

if first == 1:
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

from collections import deque

s = deque(input())
q = int(input())
first = 1

for i in range(q):
    t = input().split()
    if int(t[0]) == 1:
        first *= -1
    else:
        f = int(t[1])
        c = t[2]
        
        if first == 1:
            if f == 1:
                s.appendleft(c)
            elif f == 2:
                s.append(c)
        else:
            if f == 1:
                s.append(c)
            elif f == 2:
                s.appendleft(c)

S = "".join(s)
if first == 1:
    print(S)
else:
    print(S[::-1])
### BUGGY CODE ###

N = int(input())
s = input()
l = []
c = 0
d = 0
ans = 10**6

if s.count("#")==0:
    print(0)
else:
    for i in range(N):
        if s[i] == "#":
            if d != 0:
                c += 1
                d += 1
            else:
                l.append(c + s[i:N+1].count("."))
                c += 1
                d += 1
        d = 0
    print(min(l))

        



### FIXED CODE ###

N = int(input())
s = input()
l = []
b = 0
w = s.count(".")

for i in range(N):
    if s[i] == "#":
        l.append(b+w)
        b += 1
    else:
        w -= 1
        l.append(b+w)
print(min(l))
### BUGGY CODE ###

import bisect
import math
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = [0,0]
max = 0
i = n-1
if n == 2:
	ans[0] = a[1]
	ans[1] = a[0]
else:
	while i > (89999*n//90000-1):
		if a[i]%2 == 0:
			temp = n-1
			while a[i]//2 < a[temp]:
				temp += -1
			
			if a[i] > a[temp-1]:
				if (a[i]//2-a[temp-1]) <= (a[temp+1]-a[i]//2):
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp-1])*math.factorial(a[temp-1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp-1]
				else:
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp+1])*math.factorial(a[temp+1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp+1]
		else:
			temp1 = n-1
			temp2 = n-1
	
			while (a[i]+1)//2 < a[temp1]:
				temp1 += -1
			while (a[i]-1)//2 < a[temp2]:
				temp2 += -1
			
			if a[i] > a[temp1-1]:
				if (a[i]//2-a[temp1-1]) <= (a[temp1+1]-a[i]//2):
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp1-1])*math.factorial(a[temp1-1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp1-1]
				else:
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp1+1])*math.factorial(a[temp1+1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp1+1]
		
			if a[i] > a[temp2-1]:
				if (a[i]//2-a[temp2-1]) <= (a[temp2+1]-a[i]//2):
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp2-1])*math.factorial(a[temp2-1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp2-1]
				else:
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp2+1])*math.factorial(a[temp2+1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp2+1]
		i += -1
print(ans[0],ans[1])

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
mxm = max(a)
div = []
for i in range(n):
    div.append(abs(mxm/2.0-a[i]))
mini = min(div)
ind = div.index(mini)

if n == 2:
    print(max(a),min(a))
else:
    print(mxm,a[ind])
### BUGGY CODE ###

import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'101': ' ', '000000': "'", '000011': ',', '10010001': '-',
        '010001': '.', '000001': '?', '100101': 'A', '10011010': 'B',
        '0101': 'C', '0001': 'D', '110': 'E', '01001': 'F', '10011011': 'G',
        '010000': 'H', '0111': 'I', '10011000': 'J', '0110': 'K', '00100': 'L',
        '10011001': 'M', '10011110': 'N', '00101': 'O', '111': 'P', '10011111': 'Q',
        '1000': 'R', '00110': 'S', '00111': 'T', '10011100': 'U', '10011101': 'V',
        '000010': 'W', '10010010': 'X', '10010011': 'Y', '10010000': 'Z'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans = ""
    a, i = 0, 3
    while a+i != len(d):
        i = 3
        while i<9:
            if code.get(d[a:a+i], None) is not None:
                ans += code[d[a:a+i]]
                a += i
                break
            i += 1
    print(ans)

### FIXED CODE ###

import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'101': ' ', '000000': "'", '000011': ',', '10010001': '-',
        '010001': '.', '000001': '?', '100101': 'A', '10011010': 'B',
        '0101': 'C', '0001': 'D', '110': 'E', '01001': 'F', '10011011': 'G',
        '010000': 'H', '0111': 'I', '10011000': 'J', '0110': 'K', '00100': 'L',
        '10011001': 'M', '10011110': 'N', '00101': 'O', '111': 'P', '10011111': 'Q',
        '1000': 'R', '00110': 'S', '00111': 'T', '10011100': 'U', '10011101': 'V',
        '000010': 'W', '10010010': 'X', '10010011': 'Y', '10010000': 'Z'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans=tmp=""
    for c in d:
        tmp += c
        if tmp in code:
            ans += code[tmp]
            tmp = ""
    print(ans)
### BUGGY CODE ###

MOD = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0] * (S + 1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    a = A[i]
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2
        dp[i+1][j] %= MOD
        if j + a <= S:
            dp[i+1][j+a] += dp[i][j]
            dp[i+1][j+a] %= MOD
print(dp[N][S])


### FIXED CODE ###

MOD = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0] * (S + 1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    a = A[i]
    for j in range(S+1):
        dp[i+1][j] += dp[i][j] * 2
        dp[i+1][j] %= MOD
        if j + a <= S:
            dp[i+1][j+a] += dp[i][j]
            dp[i+1][j+a] %= MOD
print(dp[N][S])
### BUGGY CODE ###

s_l = list(input())
n = len(s_l)

# 公式解説参照
dp = [0]
t = 0
for i in range(n):
    a = int(s_l[-(i+1)])
    t = (t + a*(10**i))%2019
    dp.append(t)

ans = 0
for i in range(2019):
    m = dp.count(i)
    ans += m*(m-1)//2

print(ans)


### FIXED CODE ###

s_l = list(input())
n = len(s_l)

# 公式解説参照
dp_dict = {0:1}
t = 0
for i in range(n):
    a = int(s_l[-(i+1)])
    t = (t + a*(pow(10,i,2019)))%2019
    dp_dict[t] = dp_dict.get(t,0) + 1

ans = 0
for val in dp_dict.values():
    ans += val*(val-1)//2

print(ans)
### BUGGY CODE ###

# 1.input
n = int(input())
a = list(map(int, input().split()))

#2. choose maximum number as a_i and remove
ai = max(a)
a.remove(ai)

# 3. choose the nearest number from (a_i/2) as a_j
ideal = int(ai/2)
dist = 0
while 1:
    if (ideal-dist) in a:
        aj = ideal-dist
        break
    if (ideal+1+dist) in a:
        aj = ideal+1+dist
        break
    dist += 1
    
print("{} {}".format(ai, aj))

### FIXED CODE ###

# 1.input
n = int(input())
a = list(map(int, input().split()))

#2. choose maximum number as a_i and remove
ai = max(a)
a.remove(ai)

# 3. choose the nearest number from (a_i/2) as a_j
abs_dist = [abs(a_temp-(ai/2)) for a_temp in a]
chosen_temp = min(abs_dist)
aj = a[abs_dist.index(chosen_temp)]

print("{} {}".format(ai, aj))
### BUGGY CODE ###

from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
mo=10**9+7
imp='IMPOSSIBLE'


s=input()
t=list(s)[::-1]
ans=0
dp=[0]*13
dp[0]=1
for d in range(len(t)):
    
    if t[d]=='?':
        tm=[0]*13
        for x in range(10):
            r=int(x)*(10**d)
            for i in range(13):
                tm[(i+r)%13]+=dp[i]
        dp=[j%mo for j in tm]
    else:
        tm=[0]*13
        r=int(t[d])*(10**d)
        for i in range(13):
            tm[(i+r)%13]=dp[i]
        dp=[j for j in tm]
    #print(dp)

print(dp[5]%mo)


### FIXED CODE ###

from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
mo=10**9+7
imp='IMPOSSIBLE'


s=input()
t=list(s)[::-1]
ans=0
dp=[0]*13
dp[0]=1
for d in range(len(t)):
    
    if t[d]=='?':
        tm=[0]*13
        for x in range(10):
            r=int(x)*pow(10,d,13)
            for i in range(13):
                tm[(i+r)%13]+=dp[i]
        dp=[j%mo for j in tm]
    else:
        tm=[0]*13
        r=int(t[d])*pow(10,d,13)
        for i in range(13):
            tm[(i+r)%13]=dp[i]
        dp=[j for j in tm]
    #print(dp)

print(dp[5]%mo)
### BUGGY CODE ###

def main():
    N, M = map(int, input().split())
    P = []
    Y = []
    for _ in range(M):
        pi, yi = [int(i) for i in input().split()]
        P.append(pi)
        Y.append(yi)
    temp_dict = {}
    for i in range(N):
        temp_list = [Y[k] for k, x in enumerate(P) if x == i+1]
        temp_list.sort()
        for i in range(len(temp_list)):
            temp_dict[str(temp_list[i])] = i+1

    for i in range(M):
        print(str(P[i]).zfill(6) + str(temp_dict[str(Y[i])]).zfill(6))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, M = map(int, input().split())
    Lw = []
    T = []
    for _ in range(M):
        pi, yi = [int(i) for i in input().split()]
        T.append(pi)
        T.append(yi)
        Lw.append(T)
        T = []
    temp_dict = {}
    answer_dict = {}
    L = Lw.copy()
    L.sort(key=lambda x: x[1])
    for i in range(N):
        temp_dict[str(i+1)] = 1
    for l in L:
        answer_dict[str(l[1])] = temp_dict[str(l[0])]
        temp_dict[str(l[0])] += 1

    for lw in Lw:
        print(str(lw[0]).zfill(6) + str(answer_dict[str(lw[1])]).zfill(6))


if __name__ == "__main__":
    main()