peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
cnt = 0
ans = 0
for a,b in ab:
  cnt += b
  ans += a * b
  if cnt >= m:
    if cnt > m: ans -= a * (cnt-m)
    break
print(ans)
# Judge status: Accepted
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
Q = int(input())
B, C = [], []
for i in range(Q):
	b, c = map(int, input().split())
	B.append(b)
	C.append(c)
	
dic = Counter(A)
ans = 0
for k, v in dic.items():
	ans += k*v
for i in range(Q):
	b, c = B[i], C[i]
	dic[c] += dic[b]
	ans += - b*dic[b] + c*dic[b]
	del dic[b]
	print(ans)
# Judge status: Wrong Answer
w,h,n = map(int,input().split())
xya = [list(map(int,input().split())) for i in range(n)]
minx = 0
maxx = w
miny = 0
maxy = h

for i in range(n):
  if xya[i][2] == 1:
    minx = xya[i][0]
  if xya[i][2] == 2:
    maxx = xya[i][0]
  if xya[i][2] == 3:
    miny = xya[i][1]
  if xya[i][2] == 4:
    maxy = xya[i][1]
      
if minx >= maxx or miny >= maxy:
  print(0)
else:
  print((maxx-minx)*(maxy-miny))
# Judge status: Accepted
import sys
def I():
    return int(sys.stdin.readline().rstrip())

N = I()

if N == 0:
    print(0)
    exit()

ans = ''

r = 0
while N != 0:
    if N % 2 == 1:
        ans = '1' + ans
        N -= (-1)**r
    else:
        ans = '0' + ans
    N //= 2
    r += 1

print(ans)
# Judge status: Accepted
def fac(n, p):
    ret = 1
    for i in range(2, n + 1):
        ret = ret * i % p
    return ret

N, M = [int(x) for x in input().split()]
p = 10 ** 9 + 7
if abs(N - M) >= 2:
    ans = 0
elif N == M:
    ans = 2 * fac(N, p) * fac(M, p) % p
else:
    ans = fac(N, p) * fac(M, p) % p

print(ans)
# Judge status: Wrong Answer
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())


dishes = [A, B, C, D, E]
tens = 0
ones = 9
muda = 0
for d in dishes:
    if d % 10 == 0:
        tens += d // 10
    else:
        tens += d // 10 + 1
        if d % 10 < ones:
            muda = d
            ones = d % 10

#%%
ans = tens * 10 -  (10 -muda % 10)

print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    *a, = map(int, input().split())

    bool_ = any(x for x in a if (x % 2 == 0) and not (x % 3 == 0 or x % 5 == 0))

    print('DENIED' if bool_ else 'APPROVED')


if __name__ == '__main__':
    main()
# Judge status: Accepted
x = int(input(''))

if x == 0:
    x = 1
else:
    x = 0

print(x)
# Judge status: Accepted
print("ABC" if int(input())<1000 else "ABD")
# Judge status: Accepted
#!/usr/bin/env python3
from math import ceil
n, a, b, c, d, e = map(int, open(0).read().split())
s = min(a, b, c, d, e)
print(4 + ceil(n/s))
# Judge status: Accepted
N = int(input())

for i in range(1,10):
    tmp = i * 111
    if (N <= tmp):
        print(tmp)
        break
# Judge status: Wrong Answer
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
from itertools import permutations
p,q=0,0
for i,R in enumerate(permutations(range(1,N+1))):
    if P==R:
        p=i
    elif Q==R:
        q=i
print(abs(p-q))
# Judge status: Accepted
N, M = map(int, input().split())
dp = [0 for _ in range(N+1)]
skip = {}

for _ in range(M):
    skip[int(input())] = 1

dp[1] = 1
if N >= 2:
    dp[2] = 2

if 1 in skip:
    dp[1] = 0
    if N >= 2:
        dp[2] = 1
if 2 in skip:
    if N >= 2:
        dp[2] = 0

for i in range(3, N+1):
    if i in skip:
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[N])
# Judge status: Accepted
a,b=map(int,input().split())
print("Draw" if a==b else "Bob" if (a+13)%15<(b+13)%15 else "Alice")
# Judge status: Accepted
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
MOD = 10 ** 9 + 7


n, m = LI()
if abs(n - m) > 1:
    print(0)
    sys.exit()

ans = 1
for i in range(1, n + 1):
    ans = ans * i % MOD
for i in range(1, m + 1):
    ans = ans * i % MOD
if n == m:
    ans = ans * 2 % MOD
print(ans % MOD)
# Judge status: Accepted
import math
n,k=map(int,input().split());a=list(map(int,input().split()))
print([math.ceil((n-k)/(k-1))+1,1][n==k])
# Judge status: Wrong Answer
N = int(input())
V = list(map(int, input().split()))

C = sorted(V)
print(C)
ans = 0

a = C[0]
for i in range(1, N):
    a = (a + C[i]) / 2
ans = max(ans, a)
print(ans)
# Judge status: Wrong Answer
a = int(input())
s = input()
print("red" if a >= 3200 else "s")
# Judge status: Accepted
# ABC131
# A Security
S  = input()
sl = len(S)
for i in range(sl-1):
    if S[i] == S[i+1]:
        print('Bad')
        exit()
print('Good')
# Judge status: Wrong Answer
import sys

n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
	numa,numb=map(int,input().split())
	a.append(numa)
	b.append(numb)
bb=[]
aa=[]
if not 1 in a or not n in b:
	print("IMPOSSIBLE")
	sys.exit()
for j in range(len(a)):
    if 1==a[j]:
        bb.append(b[j])
for k in range(len(b)):
    if n==b[k]:
        aa.append(a[k])
print(aa)
print(bb)
list=set(aa) & set(bb)
print("IMPOSSIBLE" if len(list)==0 else "POSSIBLE")
# Judge status: Accepted
S = input()
if (S.count('S') > 0) == (S.count('N') > 0) and (S.count('E') > 0) == (S.count('W') > 0):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
A, B, C, X, Y = map(int, input().split())

a = A*X+B*Y

if 2*C < A+B:
    b = max(X,Y)*C*2
else:
    b = min(X, Y) * C * 2
    if X > Y:
        b += A * (X-Y)
    elif X < Y:
        b += B * (Y-X)


print(min(a, b))
# Judge status: Accepted
i = list(map(int, input().split()))
A = i[0]
B = i[1]
C = i[2]
if A == B != C :
  print('Yes')
elif A != B == C :
  print('Yes')
elif A == C != B :
  print('Yes')
else :
  print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

d = {x:0 for x in range(1, 1+N)}
for x in A:
    d[x] += 1
    
print('\n'.join(map(str,d.values())))
# Judge status: Accepted
import copy
n, m = map(int, input().split())
H = list(map(int, input().split()))
ANS = copy.deepcopy(H)

for i in range(m):
  a, b = map(int, input().split())
  if H[a-1] > H[b-1]:
    ANS[b-1] = 0
  elif H[a-1] == H[b-1]:
    ANS[a-1] = 0
    ANS[b-1]= 0
  else:
    ANS[a-1] = 0
ans = 0
for i in range(n):
  if ANS[i] != 0:
    ans += 1
print(ans)
# Judge status: Accepted
# 大きくなるように取る
# 1 -> 5 -> 6 -> 5かな
# 1 6 12 17 23
N = int(input())
cnt = 0
a = N // 11
amari = N % 11
cnt += a*2
# print(a, amari)
if amari == 0:
    cnt += 0
elif amari <= 6:
    cnt += 1
else:
    cnt += 2
print(cnt)
# Judge status: Accepted
## C - Unification
S = list(input())
cnt1 = len([i for i in range(len(S)) if S[i] == '1'])
cnt0 = len([i for i in range(len(S)) if S[i] == '0'])
print(min(cnt0,cnt1)*2)
# Judge status: Accepted
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

total = 0
for a in A_list:
    total += B_list[a-1]

for i in range(N-1):
    if A_list[i] + 1 == A_list[i + 1]:
        total += C_list[A_list[i]-1]

print(total)
# Judge status: Wrong Answer
#--Palindrome-philia

S = input()
s_str = list(S)
s_rev = s_str[::-1]
print(s_str)
print(s_rev)

num = len(s_str)

j = 0
for i in range(num):
  if (s_str[i] == s_rev[i]):
    pass
  else:
    j = j + 1

print (j/2)
# Judge status: Accepted
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N = int(input())
nums = [int(i) for i in input().split()]

print(gcd_list(nums))
# Judge status: Accepted
import collections
import math
n=int(input())
s=[]
for i in range(n):
    sl=list(input())
    sl.sort()
    s.append("".join(sl))

l=list(collections.Counter(s).values())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    k=int(l[i])
    if k!=1:c+=combinations_count(k,2)
print(c)
# Judge status: Wrong Answer
n = input()
if len(n) == 6: print("90909")
if len(n) == 5: print(909 + int(n) - 9999)
if len(n) == 4: print("909")
if len(n) == 3: print(9 + int(n) - 99)
if len(n) == 2: print("9")
else: print(int(n))
# Judge status: Accepted
N=int(input())
L=list(map(int,input().split()))
S=[0]*N
c=1
for i in L:
    S[i-1]=c
    c+=1
for i in range(N):
    print(S[i],end=' ')
# Judge status: Accepted
# coding: utf-8
X = int(input())
f = X // 500
ans = 0
ans += 1000 * f
X -= f * 500
f = X // 5
ans += 5 * f
print(ans)
# Judge status: Accepted
N = int(input())
X = sorted(list(map(int, input().split(" "))))
min = -1
for i in range(X[0], X[-1]+1):
  s = sum((x - i) ** 2for x in X)
  if min == -1:
    min = s
  if s < min:
    min = s
print(min)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
while(a>=0 or c>=0):
    c-=b
    if c<=0:
        print("Yes")
        break
    a-=d
    if a<=0:
        print("No")
        break
# Judge status: Accepted
import math
A,B,N=map(int,input().split())
x=min(B-1,N)
print(math.floor(A*x/B) - A*math.floor(x/B))
# Judge status: Accepted
n = int(input())
A = sorted([a-i-1 for i, a in enumerate(map(int, input().split()))])

med_A = A[n//2]
ans = sum([abs(a-med_A) for a in A])

print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

a,b=map(int,input().split())
if a%3==0 or b%3--0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))

n,k=I()
l=I()
lo=1;hi=max(l)
while lo<hi:
	md=(lo+hi)//2
	ct=0
	for i in range(n):
		ct+=l[i]//md-(l[i]%md==0)
	if ct<=k:
		hi=md
	else:
		lo=md+1
print(lo)
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
# Judge status: Wrong Answer
s = int(input())

ans = 0

if s%10==1:
  ans += 1

s = s//10
if s%10==1:
  ans += 1

s = s//10
if s==1:
  ans += 1
  
print(ans+1)
# Judge status: Accepted
h, m, h2, m2, k = map(int, input().split())
print(max(0, (h2*60+m2)-(h*60+m)-k))
# Judge status: Accepted
n,m=map(int,input().split())
l=set(range(1,m+1))
for i in range(n):
    k,*a=map(int,input().split())
    l&=set(a)
print(len(l))
# Judge status: Wrong Answer
# スペース区切りの整数の入力
N, *d = map(int, open(0).read().split())

if N > 0:
	A = 1
	for O in d:
		A = A * O
		print(O)
		if A >= 10 ** 18:
			A = -1
			break
else:
	A = 0

print(A)
# Judge status: Wrong Answer
n, m = map(int,input().split())

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

temp_h = h.copy()

for _ in range(m):
    x1, x2 = map(int,input().split())

    temp_h[x1 - 1] = max([temp_h[x1 - 1], temp_h[x2 - 1]])
    temp_h[x2 - 1] = max([temp_h[x1 - 1], temp_h[x2 - 1]])

res = [1 if x - y else 0 for x, y in zip(h, temp_h)]

print(sum(res))
# Judge status: Accepted
D,N=map(int,input().split())
print(((100**D)*N) if N<100 else ((N+1)*(100**D)))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

b = [-1] * (n + 2)

mid = n // 2
left = mid - 1
right = mid + 1

b[mid] = a[0]

for i in range(1, n):
  if i % 2 != 0:
    b[left] = a[i]
    left -= 1
  else:
    b[right] = a[i]
    right += 1

for i in b:
  if i < 0:
    continue
  print(i)
# Judge status: Accepted
#!/usr/bin/env python3
def main():
    h = int(input())
    w = int(input())
    n = int(input())
    if h > w:
        h, w = w, h
    for y in range(h):
        n -= w
        if n <= 0:
            break
    print(y + 1)
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
# C - Typical Stairs

MOD = (10 ** 9) + 7
N, M = map(int, input().split())
A = [False] * (N + 1)
for _ in range(M):
    A[int(input())] = True
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in A:
    dp[1] = 1

for i in range(2, N + 1):
    if A[i]:
        dp[i] = 0
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

print(dp[N])
# Judge status: Accepted
S = input()

zero_count = int(S.count('0'))
one_count = int(S.count('1'))

print(min(zero_count, one_count)*2)
# Judge status: Accepted
r = int(input())
p = 3.141592653589793
print(2*r*p)
# Judge status: Wrong Answer
a = int(input())
s = input()
if a > 3200:
  print("red")
else:
  print(s)
# Judge status: Wrong Answer
#N枚のお金N，合計金額Y
N, Y = map(int, input().split())
 
"""
a = 0 #1000円札の枚数
b = 0 #5000円札の枚数
c = 0 #10000円札の枚数
 
X = 0 #合計金額
"""
 
for a in range(N+1):
    for b in range(N-a+1):
        X = 1000*a + 5000*b + 10000*(N-a-b)
        if X == Y:
            print(a, b, N-a-b)
            exit()
 
 
print("-1 -1 -1")
# Judge status: Accepted
def factorize(n):
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  return fct

def getpattern(x):
  pattern = 0
  d = 0
  for i in range(1, 1000000):
    d += i
    if x < d:
      break
    pattern += 1
  return pattern

n = int(input())
f = factorize(n)
fu = set(factorize(n))
r = 0
for fui in fu:
  r += getpattern(f.count(fui))
print(r)
# Judge status: Wrong Answer
n = int(input())
ans = 0
s = 0
for i in range(1,n+1):
    if s >= n:
        break
    s += i
    ans += 1
ans -= 1
a = n
for i in range(ans):
    if a >= ans+1-i:
        print(ans+1-i)
        a -= ans+1-i
    elif a == 0:
        break
    else:
        print(a)
        break
if n == 1:
    print(1)
# Judge status: Accepted
import numpy as np
N,M=map(int,input().split())
A=np.array(list(map(int,input().split())))
A=A>=np.sum(A)/(4*M)
if np.sum(A)>=M:
    print('Yes')
else:print('No')
# Judge status: Wrong Answer
N = int(input())
S = input()
strs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for s in S:
    ind = strs.index(s) + N
    if ind >= 26:
        ind = ind - 26
    print(strs[ind])
# Judge status: Wrong Answer
K = int(input())    
count = 0
i = 0
j = 0

if K == 2:
    count = 1

elif K == 3:
    count = 2

elif K > 3:
    while i < K:
        i += 1
        j = i + 1

        while j <= K:
            
            count += 1
            
            j += 2
            print(count)

print(count)
# Judge status: Accepted
S, W = map(int, input().split())
if S <= W:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
n = int(input())
a = int(n**0.5+1)
ans = [0]*n
for x in range(1, a):
    for y in range(1, a):
        for z in range(1, a):
            if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
                ans[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1
[print(i) for i in ans]
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sorted(a)
    
    for i in range(n):
        if a[i] <=  b[n // 2 - 1]:
            print(b[n // 2])
        elif a[i] >  b[n // 2 - 1]:
            print(b[n // 2 - 1])
        
        
if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
if s.islower():
  print('a')
else:
  print('A')
# Judge status: Accepted
s = int(input())
a = [s]
for i in range(10000):
    if a[i] %2 == 0:
        b = a[i]//2
        if b in a:
            print(i+2)
            exit()
        a.append(b)
    else:
        b = 3*a[i]+1
        if b in a:
            print(i+2)
            exit()
        a.append(b)
# Judge status: Wrong Answer
n = int(input())

num = n // 2
ans = 1
for i in range(num+1):
    ans = ans * 2
print(ans-1)
# Judge status: Wrong Answer
import sys 
N, M = map(int, input().split())
X = list(map(int, input().split()))

X = sorted(X)

anslis = []


if M <= N:
    print(0)
    sys.exit()


    
for i in range(M-1):
    ans = abs(X[i+1] - X[i])
    anslis.append(ans)
    ans = 0

anslis = sorted(anslis)

print(sum(anslis[0:N-1]))
# Judge status: Accepted
n,l=map(int,input().split())
s=sorted([input() for _ in range(n)])
print(*s, sep="")
# Judge status: Accepted
K = int(input())
if K % 2 == 0:
    print((K // 2) ** 2)
else:
    print((K//2 + 1) * (K//2))
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N > K:
  print(X*K + Y*(N-K))
else:
  print(X*N)
# Judge status: Accepted
n = int(input())
a = sorted([int(input()) for i in range(n)])
ans = 0
s = 1
for i in range(n - 1):
  if a[i] != a[i + 1]:
    ans += s % 2
    s = 1
  else:
    s += 1
ans += s % 2
print(ans)
# Judge status: Accepted
a, b, x = map(int, input().split())
def solve(a,b,x):
  ans =  b//x - (a-1)//x
  # print(ans)
  return ans
print(solve(a,b,x))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print("Yes" if c < a + b else "No")
# Judge status: Accepted
def main():
    a, b, c, operation = map(int, input().split())
    answer = a - b
    if abs(answer) > 10 ** 18:
        print("Unfair")
    else:
        if operation % 2:
            print(answer * -1)
        else:
            print(answer)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N=int(input())
A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9]

for n in range(N):
    temp=str(n)
    r=int(temp[-1])
    l=int(temp[0])
    if r!=0 and l!=0:
        A[r-1][l-1]+=1

ans=0
for i in range(9):
    for j in range(9):
        ans+=A[i][j]*A[j][i]
if N==1:
    print(1)
else:
    print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())

print(N - (N // K) * K)
# Judge status: Wrong Answer
n = int(input())
if n < 105:
    print(0)
elif n < 165:
    print(1)
elif n < 195:
    print(2)
else:
    print(3)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(1,n-1):
  l = p[i-1:i+2]
  if l[1] == sorted(l)[1]:
    cnt+=1
    
print(cnt)
# Judge status: Accepted
def main():
    N = int(input())
    A = [0] + [int(i) for i in input().split()]
    C = [0]*(N+1)
    for i in range(1, N+1)[::-1]:
        cur = 0
        for j in range(i, N+1, i):
            cur += C[j]
        if cur % 2 != A[i] % 2:
            C[i] += 1
    M = sum(C)
    print(M)
    if M:
        C = [i for i in range(1, N+1) if C[i]]
        print(*C)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import numpy as np

def Rally(n, array):
    min_ = max(np.array(array)*100)
    for i in range(0,max(np.array(array))):
        if min_ > sum((np.array(array)-i)**2):
            min_ = sum((np.array(array)-i)**2)
    return min_

n = int(input())
array = list(map(int,input().split()))
print(Rally(n, array))
# Judge status: Accepted
a,b,c=map(int, input().split())
if (a==b or b==c or c==a)and not (a==b and b==c):
        print('Yes')
else:
        print('No')
# Judge status: Accepted

import math
X = int(input())

print ((X*360//math.gcd(X,360)) // X)
# Judge status: Accepted
H,W,N=map(int,input().split())
sita,hidari=0,0
ue,migi=W,H
for i in range(N):
  x,y,a=map(int,input().split())
  if a==1:
    hidari=max(x,hidari)
  elif a==2:
    migi=min(migi,x)
  elif a==3:
    sita=max(sita,y)
  else:
    ue=min(ue,y)
print(max(0,(migi-hidari))*max(0,(ue-sita)))
# Judge status: Accepted
s = input()
n = len(s)
white_start = ["0" if i%2==0 else "1" for i in range(n)]
#black_start = ["1" if i%2==0 else "0" for i in range(n)]


Wcnt = 0
#Bcnt = 0

for i in range(n):
  if s[i]!=white_start[i]:
    Wcnt +=1
  #else:
    #Bcnt +=1
print(min(Wcnt,n-Wcnt))
# Judge status: Accepted
import collections
S = input()
c = collections.Counter(S)
 

if (len(c.keys()) == 2 )and(list(c.values()) == [2,2]):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n = int(input())

square_roots = [i**2 for i in range(n) if i**2<=n]
print(max(square_roots))
# Judge status: Accepted
import bisect
N,M = map(int,input().split())
maxa = M//N
def make_divisors(n):
    divisors = []
    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)
    return divisors
mdiv = sorted(make_divisors(M))
ans = mdiv[bisect.bisect_right(mdiv,maxa)-1]
print(ans)
# Judge status: Wrong Answer
n = int(input())

s = list(input())

ans = 0

for i in range(n):
    x = s[:i+1]
    y = s[i:]
    ans = max(ans,len(set(x)&set(y)))
# Judge status: Wrong Answer
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []

for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        total.append(k + j)
        break
      
if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and 7 and 8) in total) or ((0 and 3 and 6) in total) or ((1 and 4 and 7) in total) or ((2 and 5 and 8) in total) or ((0 and 4 and 8) in total) or ((2 and 4 and 6) in total):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
# TLE
s = input()
q = int(input())
reverse_flag = False
prefix = ''
suffix = ''
for _ in range(q):
  query = input()
  if query == '1':
    if reverse_flag:
      reverse_flag = False
    else:
      reverse_flag = True
  else:
    if reverse_flag and query[2] == '1':
      suffix += query[4]
    elif not reverse_flag and query[2] == '2':
      suffix += query[4]
    else:
      prefix += query[4]

if reverse_flag:
  print(suffix[::-1] + s + prefix)
else:
  print(prefix[::-1] + s + suffix)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input()) * 10
    print((n + 54) // 55)
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""
# Judge status: Accepted
from collections import defaultdict
dic = defaultdict(int)
N,M = map(int,input().split())
A = []
for i in range(M):
  a,b = map(int,input().split())
  A.append((a,b,i))
A.sort()
#print(A)
ans = [-1 for _ in range(M)]
for i in range(M):
  dic[A[i][0]] += 1
  #print(dic[A[i][0]])
  temp = "0"*(6-len(str(A[i][0])))+str(A[i][0])+"0"*(6-len(str(dic[A[i][0]])))+str(dic[A[i][0]])
  ans[A[i][2]] = temp
  #print(i,temp)
for t in ans:
  print(t)
# Judge status: Wrong Answer
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)


N,M = map(int, input().split())
xs = map(int, input().split())
r = 1
for x in xs:
    r = lcm(x,r)
if r//2 > M:
    print(0)
else:
    print((M-r//2)//r+1)
# Judge status: Wrong Answer
import sys
n=int(input())
if n == 1:
    print(0)
    sys.exit()
tmp=n
ans=0
for i in range(2,n):
    if tmp % i == 0:
        tmp = tmp // i
        ans += 1
        continue
    if i > tmp:
        break
    if i > tmp // i:
        ans+=1
        break
print(ans)
# Judge status: Accepted
N=int(input())
H=list(map(int,input().split()))
x=0
l=[]
for i in range(N-1):
    if H[i]>=H[i+1]:
        x+=1
    else:
        l.append(x)
        x=0
l.append(x)
print(max(l))
# Judge status: Wrong Answer
N = int(input())
S = input()

if (N%2 != 0):
    print('No')
else:
    n = N//2
    for i in range(n):
        if (S[i] != S[n+i]):
            print('No')
            break
    if (i == n-1):
        print('Yes')
# Judge status: Accepted
N = int(input())
Alist = list(map(int,input().split()))
Blist = []
p = 0
q = 0
r = 0
for i in range(N):
    Blist.append(Alist[i] - i- 1)
Blist.sort()
u = Blist[N//2]
for i in range(N):
    q = q + abs(Blist[i]-u)
print(q)
# Judge status: Accepted
d,t,s = map(int,input().split())
if t*s >=d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,k = map(int, input().split())
s = input()

rl_cnt = 0
for s1,s2 in zip(s[:-1],s[1:]):
    if s1 == 'R' and s2 == 'L':
        rl_cnt += 1

left_happy = 1 if s[0] == 'R' else 0
right_happy = 1 if s[-1] == 'L' else 0

first_happy = n - rl_cnt*2 -2 + left_happy + right_happy
print(first_happy)
if k <= rl_cnt:
    print(first_happy + k*2)
else:
    rem = k-rl_cnt
    ans = first_happy + rl_cnt*2 + min(rem, left_happy+right_happy)
    print(ans)