peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
def cnt(s, b):
	ans = []
	for i in s:
		if i in b:
			ans.append(i)
	return ans

def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	cnt1 = cnt(lst1, lst3)
	cnt2 = cnt(lst2, lst3)

	if len(cnt1) > len(cnt2):
		return cnt2
	else:
		return cnt1

def resolve():
	n = int(input())
	h = []
	for i in range(n):
		h.append(input())
	sec = h[0]
	for i in range(1, n):
		sec = intersection(sec, h[i])
	print("".join(sorted(sec)))
resolve()
# Judge status: Wrong Answer
n, t = map(int, input().split())
ct = []
for i in range(n):
    c, time = map(int, input().split())
    ct.append([c, time])
min_t = t
cost = 0
cnt = 0
for i in range(n):
    if ct[i][1] > t:
        cnt += 1
    else:
        if min_t >= ct[i][1]:
            min_t = ct[i][1]
            cost = ct[i][0]
if cnt == n:
    print('TLE')
else:
    print(cost)
# Judge status: Wrong Answer
n = int(input())
k = 1
while True:
  if k*(k+1)//2 >= n:
    ans = k
    break
  k += 1
cnt = 0
l = []
i = ans-1
while i > 0:
  if cnt <= n - ans*(ans-1)//2:
    l.append(i+1)
    cnt += 1
  else:
    l.append(i)
  i -= 1
while len(l) > 0:
  j = l.pop()
  print(j)
# Judge status: Accepted
str = input()
print("vowel" if str == "a" or str == "i" or str == "u" or str == "e" or str == "o" else "consonant")
# Judge status: Accepted
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())),reverse=True)
if n<=k:
    print("0")
else:
    print(sum(h[k:]))
# Judge status: Wrong Answer
a,b,k = map(int,input().split())
count = 0
if b >= a:
    count = a
    b = a
    a = count
ch = 1
for i in range(a,0,-1):
    if a % i == 0 and b % i == 0 and k == ch:
        print(i)
        break
    elif a % i == 0 and b % i == 0:
        ch += 1
# Judge status: Accepted
S=input()
print( min(abs(753-int(S[i:i+3]) ) for i in range(len(S)-2) ) )
# Judge status: Accepted
n = int(input())
arr = list(str(n))

if arr[0] == arr[1] and arr[1] == arr[2]:
    print('Yes')
elif arr[1] == arr[2] and arr[2] == arr[3]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# 隣り合う長さの最大値をKから引く
circ_length, n_house = map(int, input().split())
places = list(map(int, input().split()))

delta_places = []
for i in range(n_house):
  d = abs(places[i] - places[i-1])
  delta_places.append(d)

result = circ_length - max(delta_places)
print(result)
# Judge status: Accepted
N = int(input())
s = list(map(int,input().split()))
M = max(s)
count = [0] * (M+1)
for i in range(1,N):
    count[s[i]] += 1
ans = 0

for j in count:
    if j == 0:
        continue
    ans += int(j*(j-1)/2)
print(ans)
for i in range(1,N):
    ans += count[s[i-1]]
    count[s[i-1]] += 1
    count[s[i]] -= 1
    ans -= count[s[i]]
    print(ans)
# Judge status: Accepted
# D
N = int(input())

al = [chr(ord('a') + i) for i in range(26)]

def dfs(S, i):
    if len(S) == N:
        yield ''.join(S)
        return
    for j in range(i):
        for w in dfs(S + [al[j]], i):
            yield w
    for w in dfs(S + [al[i]], i + 1):
        yield w

for w in dfs([], 0):
    print(w)
# Judge status: Wrong Answer
from math import gcd
k = int(input())
gcdl = [[0 for i in range(k + 1)]for i in range(k+1)]
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcdl[i][j] = gcd(i, j)
s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            s += gcdl[i][gcdl[j][k]]

print(s)
# Judge status: Accepted
def calc_dist(pos_a,pos_b):
  return abs(pos_a[0] - pos_b[0])+abs(pos_a[1] - pos_b[1])

n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  a.append(list(map(int,input().split())))
for i in range(m):
  b.append(list(map(int,input().split())))

for a_pos in a:
  min_d=float("inf")
  min_d_i=-1
  for i,b_pos in enumerate(b):
    d=calc_dist(a_pos,b_pos)
    if d < min_d:
      min_d=d
      min_d_i=i+1
  print(min_d_i)
# Judge status: Accepted
def main():
    from sys import stdin
    r = stdin.readline()[:-1]
    #r = stdin.readlines()

    print('Christmas'+' Eve'*(25-int(r)))
   
if __name__ == '__main__':
    main()
# Judge status: Accepted
from sys import stdin
def input():
    return stdin.readline().strip()

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    i, j = map(int, input().split())
    i -= 1
    j -= 1
    edge[i].append(j)
    edge[j].append(i)

for i in edge[0]:
    if n - 1 in edge[i]:
        print('POSSIBLE')
        exit()
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
A, B = map(int,input().split())
if A <= B:
  print(A)
else:
  print(A-1)
# Judge status: Wrong Answer
s = list(input())
n = len(s)
s.append('<')
mini = 0
maxi = 0
p = 0

for i in range(n):
    if s[i] == '<':
        mini += 1
    else:
        maxi += 1
        if s[i+1] == '<':
            p += (1 + max(mini,maxi)) * max(mini,maxi) // 2
            mini = 0
            maxi = 0

print(p)
# Judge status: Accepted
N,x = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
cnt = 0

for i in range(N):
  if i == N-1 and x > A[i]:
    break
  if x >= A[i]:
    x -= A[i]
    cnt += 1
  else:
    break
  
print(cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
first_half = 0
latter_half = sum(a)
min_diff = latter_half
for i in range(n):
    first_half += a[i]
    latter_half -= a[i]
    diff = abs(first_half - latter_half)
    min_diff = min(min_diff, diff)
print(min_diff)
# Judge status: Wrong Answer
n = int(input())
g = n / 2
h = n % 2
print(g + h)
# Judge status: Wrong Answer
N=int(input())
C=[list(map(int,input().split())) for _ in range(N-1)]

for i in range(N-1):
    c,s,f=C[i]
    ans=s+c
    for j in range(i+1,N-1):
        nc,ns,nf=C[j]
        # print('D',ans,nc,ns,nf)
        ans=max(ans,ns)
        ans+=nc
    print(ans)
print(0)
# Judge status: Accepted
N = int(input())

from collections import defaultdict
d = defaultdict(lambda: -1)		#初期値を「-1」にする

d[0] = 2
d[1] = 1
def f(n):
  if d[n] == -1:
    a = f(n-1) + f(n-2)
    d[n] = a
  return d[n]

print(f(N))
# Judge status: Wrong Answer
s = str(input())
t = str(input())
lens = len(s)
lent = len(t)

if lens < 1 or lens > 10 or (lent != lens + 1) or (s not in t):
    print('No')
else:
    print('Yes')
# Judge status: Accepted
import math

N, A, B= map(int, input().split())

if (A - B) % 2 == 0:
    print(abs(A - B) // 2)

else:

    t1 = A - 1
    t2 = B - 1
    t3 = N - A
    t4 = N - B

    t = min(t1, t2, t3, t4)

    res = t + 1 + (abs(A - B) - 1) // 2
    
    print(res)
# Judge status: Wrong Answer
a,b= input().split()

print(a+b)
# Judge status: Accepted
import math
a,b =  map(int,input().split())
lcm = a*b//math.gcd(a,b)
print(lcm)
# Judge status: Accepted
a = int(input())
if a == 0:
    print(1)
else:
    print(0)
# Judge status: Accepted
H, K = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
ans = 0
for i in range(K,len(arr)):
    ans += arr[i]
print(ans)
# Judge status: Wrong Answer
X = input().rstrip() + "#"
s0 = X[0]
P = []
cnt = 1
for s in X[1:]:
    if s==s0:
        cnt += 1
    else:
        P.append(cnt)
        cnt = 1
    s0 = s
if X[0] == "T":
    P = P[1:]
res = len(X) - 1
for i in range(0,len(P)-1,2):
    if P[i] < P[i+1]:
        res -= P[i]*2
    else:
        res -= P[i+1]*2
print(res)
# Judge status: Accepted
n = int(input())
H = list(map(int, input().split()))

cnt = 0
ans = 0
tmp = H[0]
for h in H[1:]:
    if h <= tmp:
        cnt += 1
    ans = max(ans, cnt)
    if h > tmp:
        cnt = 0
    tmp = h

    
print(ans)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
a = 0
b = 0
check = -1
for i in range(n-1):
  if l[i]==l[i+1]:
    if check != i:
      if a == 0:
        a = l[i]
        check = i+1
      elif b == 0:
        b = l[i]
print(a*b)
# Judge status: Wrong Answer
n = int(input())
s = 0

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
  

  
for i in range(n):
  s += b[i]
  
for i in range(n-1):
  if a[i+1] - a[i] == 1:
    s += c[i]
    
print(s)
# Judge status: Wrong Answer
import math
N = int(input())
i = 0
 
while N > 0:
    n = int(math.log(N, 6))
    m = int(math.log(N, 9))
    #print(m)
    N =min(N-1, abs(N-6**n), abs(N-9**m))
    #print(N)
    i += 1
print(i)
# Judge status: Accepted
x,n=map(int,input().split())
l=list(map(int,input().split()))
y=x
while True:
	if x not in l:
		print(x)
		break
	if y not in l:
		print(y)
		break
	x-=1
	y+=1
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)

for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

ans = [0]*n

for i in range(n-1):
    time = s[i] + c[i]
    for j in range(i+1,n-1):
        time = max(s[j], time//f[j]*f[j] )+c[j]
    ans[i]=time

print(*ans,sep='\n')
# Judge status: Accepted
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for _ in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + abc[i][0]
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + abc[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + abc[i][2]
print(max(dp[-1]))
# Judge status: Accepted
N, M = map(int, input().split())
if N <= 2 or M <= 2:
    if N == 1 and M ==1:
        ans = 1
    elif N == 1 or M == 1:
        ans = max(N-2, M-2)
    else:
        ans = 0
else:
    ans = (N-2)*(M-2)
print(ans)
# Judge status: Accepted
import math
n,k=map(int,input().split());input();print([math.ceil((n-k)/(k-1))+1,1][n==k])
# Judge status: Wrong Answer
n = int(input())
keta = len(str(n))
if n == 1:
  print(n)
elif n == 2:
  print(n)
elif n == 3:
  ans = 9 + n - 99
  print(ans)
elif n == 4:
  ans = 999 - 99 + 9
  print(ans)
elif n == 5:
  ans = n - 9999 + 999 - 99 + 9
elif n == 6:
  print(90909)
# Judge status: Accepted
n = int(input())
num = int(n/2)
print((n-num)/n)
# Judge status: Accepted
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append([a, b])
    g[b].append([b, a])
res = [-1 for _ in range(n+1)]
res[1] = 0
q = deque(g[1])
while q:
    q_ = q.popleft()
    if res[q_[1]] == -1:
        for gi in g[q_[1]]: q.append(gi)
        res[q_[1]] = q_[0]
print("Yes")
for i in res[2:]: print(i)
# Judge status: Accepted
N = int(input())
S = "." + input() + "#"
B = [0]*(N+2)
W = [0]*(N+2)
b = 0
for k in range(N+2):
    if S[k] == "#":
        b += 1
    B[k] = b
w = 0
for k in range(N+1,-1,-1):
    if S[k] == ".":
        w += 1
    W[k] = w
ans = 10**10
for k in range(N+1):
    ans = min(ans,B[k]+W[k+1])
print(ans)
# Judge status: Accepted
w, a, b = map(int, input().split())

print(max(a, b) - min(a, b) - w) if abs(a -  b) > w else print(0)
# Judge status: Wrong Answer
import heapq

def solve(n, a):
    a = sorted(a, reverse=True)
    ans = sum(a[:1])
    que = [(-a[1], -a[0])]
    heapq.heapify(que)
    for i in range(2, n):
        x, y = heapq.heappop(que)
        ans += min(-x, -y)
        heapq.heappush(que, (-a[i], x))
        heapq.heappush(que, (-a[i], y))
    return ans

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))
# Judge status: Accepted


from bisect import *



def resolve():
    N = int(input())
    A = [int(input()) for i in range(N)]
    A.reverse()

    B =[A[0]]

    A=A[1:]
    for  i in A:
        if i >= B[-1]:
            B.append(i)
            continue
        point = bisect_right(B,i)
        B[point]=i

    print(len(B))
if __name__ == "__main__":
    resolve()
# Judge status: Accepted
A1 = [int(_) for _ in input().split()]
A2 = [int(_) for _ in input().split()]
A3 = [int(_) for _ in input().split()]
P = [A1, A2, A3]
for i in range(3):
    P.append([A1[i], A2[i], A3[i]])
P.append([A1[0], A2[1], A3[2]])
P.append([A1[2], A2[1], A3[0]])


N = int(input())
B = []
for i in range(N):
    b = int(input())
    B.append(b)
for p in P:
    if len(set(p) & set(B)) == 3:
        print('Yes')
        break
else:
    print('No')
# Judge status: Wrong Answer
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [0] * n
for i in range(m):
  a, b = map(int, input().split())
  l[a-1] = max(h[a-1], h[b-1])
  l[b-1] = max(h[a-1], h[b-1])  
s = set(l)
if 0 in s:
  print(len(s) - 1)
else:
  print(len(s))
# Judge status: Accepted
import bisect
n=input()
a=sorted(map(int,input().split()))
m=a[-1]
q=bisect.bisect_right(a,m/2)
p=q-1
if abs(m/2-a[p])>abs(m/2-a[q]):print(m,a[q])
else:print(m,a[p])
# Judge status: Accepted
N, D = map(int, input().split())
ans = 0
while N > 0:
    N -= 2*D + 1
    ans += 1
print(ans)
# Judge status: Accepted
a, b, c, k = map(int, input().split())

flg = 0
if a - b > 0 and k % 2 == 0 or a-b < 0 and k % 2 == 0:
    flg = 1
elif a - b < 0 and k % 2 == 1 or a-b > 0 and k % 2 == 1:
    flg = -1

if abs(a-b) > 10 ** 18:
    print("Unfair")
else:
    print((a-b)*flg)
# Judge status: Accepted
s = list(input())
if len(set(s)) == 4:
    print('Yes')
elif len(set(s)) == 2:
    if ('S' in s and 'N' in s) or ('E' in s and 'W' in s):
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Wrong Answer
is_alive = [0]*8#各ランク

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

count_over=0

for i in range(0,N,1):
    if a[i]>=3200:
        count_over +=1
    else:
        is_alive[a[i]//400]=1

print(max(0,sum(is_alive)),min(sum(is_alive)+count_over,8))
# Judge status: Accepted
from fractions import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


def solve():
    N = int(input())
    ans = int(input())
    for _ in range(N - 1):
        ans = lcm(ans, int(input()))
    print(ans)


if __name__ == '__main__':
    solve()
# Judge status: Accepted
#!/usr/bin/env python3
a, b = map(int, input().split())
print(int(a + b / 2))
# Judge status: Accepted
n = int(input())
score = 0
i = 0
ans_list = []

while score < n:
    i += 1
    score += i
    ans_list.append(i)

if score == n:
    for k in range(len(ans_list)):
        print(ans_list[k])
else:
    ans_list.remove(score - n)
    for k in range(len(ans_list)):
        print(ans_list[k])
# Judge status: Wrong Answer
x,y=map(int, input().split())
S=input()
if len(S)==x+y and S[x]=='-':
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys
import io


def main():
    f = sys.stdin.buffer
    n = int(f.readline())
    h = list(map(int, f.readline().split()))
    p0, p1 = 0, abs(h[1] - h[0])
    for i in range(2, n):
        p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
        p0 = p1
        p1 = p2
    print(p1)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import argparse
import collections
import logging.config
import sys
import csv
import numpy as np

def tstr(n):
  total = n
  cnt = 1
  while total%360 != 0:
#    print (str(cnt) + "," + str(total))
    cnt += 1
    total += n 
  return (cnt)


def main():
  N = int(input())
  print (tstr(N))

if __name__ == '__main__':
    main()
# Judge status: Accepted
#! python3
#  solve127A.py

age,cost = map(int,input().split())

if age <= 5:
    cost = 0
elif 6 <= age <= 12:
    cost = cost//2
elif 7 <= age:
    cost = cost

print(cost)
# Judge status: Wrong Answer
a, b = list(map(int, input().split()))
ans = a + b if a + b <= 24 else a + b - 24
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
M = M//2

if N>=M:
    print(M)
else:
    print((N+M)//2)
# Judge status: Wrong Answer
N = int(input())
A =[2,1]
if N <= 2:
    print(A[N-1])
    exit()
for i in range(2,N):
    A.append(A[i-1]+A[i-2])
print(A[-1])
# Judge status: Wrong Answer
def culc(n, k):
    return k*(-2*k**2+3*n*k+(3*n+8))//6

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

MOD = 10**9 + 7
print(culc(N, N+1)-culc(N, K-1)%MOD)
# Judge status: Accepted

S =  input()

ans = 0

prev,now = "",""

for i in range(len(S)):
    now += S[i]
    if now != prev:
        ans += 1
        prev,now = now,""

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


A = [[1, 0]] + [[0, 1] for _ in range(n-1)]

for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    if sum(A[x]) == 1:
        if A[x][0] == 1:
            A[x][0] -= 1
            A[y][0] += 1
        else:
            A[x][1] -= 1
            A[y][1] += 1
    else:
        A[x][1] -= 1
        A[y][0] += 1


print(sum(a[0] > 0 for a in A))
# Judge status: Accepted
a,b = map(int,input().split())
if 0<a<10 and 0<b<10:
  print(a*b)
else:
  print(-1)
# Judge status: Wrong Answer
from sys import stdin
input = stdin.readline()
alpha = 'abcdefghijklmnopqrstuvwxyz'
# alpha = [i for i in alpha]
flag = False
for i in alpha:
    if flag:
        print(i)
        flag =False
    if i == input:
        flag = True
# Judge status: Accepted
a,b,c = map(int, input().split())
if a+b >= c :
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N = int(input())
WL = list(map(int, input().split()))

ALLweight = sum(WL)
HALFweight = ALLweight / 2
OVERweight = 0

for i in range(N):
    OVERweight += WL[i]
    if OVERweight >= HALFweight:
        print(abs((ALLweight-OVERweight)-OVERweight))
        exit()
# Judge status: Accepted
from decimal import Decimal, getcontext
getcontext().prec = 1000
a, b, c = map(Decimal, input().split())
print("Yes" if a+b+Decimal(2)*((a*b)**Decimal(0.5)) < c else "No")
# Judge status: Accepted
y,m,d=[int(i) for i in input().split('/')]
if y<2019:
    print('Heisei')
elif 2019<y:
    print('TBD')
else:
    if m<4:
        print('Heisei')
    elif 4<m:
        print('TBD')
    else:
        if d<=30:
            print('Heisei')
        else:
            print('TBD')
# Judge status: Wrong Answer
s = list(input())
t = list(input())
for _ in range(len(s)-1):
    if s == t:
        print("Yes")
        quit()
    else:
        end = s.pop(0)
        s.append(end)
print("No")
# Judge status: Wrong Answer
n, l = map(int, input().split())
a = list([k + l for k in range(n)])
sum_ = sum(a)
min_ = float("inf")

for j in range(n):
    min_ = min(min_, abs(a[j]))
print(sum_ - min_)
# Judge status: Wrong Answer
def main():
    S = input()
    a = S[0:2]
    b = S[2:4]

    if (int(a) >= 13 and int(b) >= 13) or (a == "00" and b == "00"):
        ans = "NA"
    elif (int(a) >= 13 and b == "00") or (int(b) >= 13 and a == "00"):
        ans = "NA"
    elif int(a) >= 13:
        ans = "YYMM"
    elif int(b) >= 13:
        ans = "MMYY"
    else:
        ans = "AMBIGUOUS"
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import collections

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)

for i in range(1, N+1):
	print(c[i])
# Judge status: Accepted
S = input()

num0 = S.count("0")
num1 = S.count("1")

print(2*min(num0, num1))
# Judge status: Accepted
import sys

S = list(input())

nS = S
i = 0

while len(nS) > 2:
    i += 1
    lns = len(S) - 2*i
    nS = S[:lns]
    nS1 = "".join(nS[:lns//2])
    nS2 = "".join(nS[lns//2:])
    if nS1 == nS2:
        print(len(nS))
        sys.exit()

print(1)
# Judge status: Accepted
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    ans = 0
    for i in range(1, n):
        ans += (n - 1) // i
    print(ans)

    return


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
x = n * 800
y = n / 20
ans = int(x) - int(y*200)
print(str(ans))
# Judge status: Accepted
c = input()

num2alpha = lambda x: chr(x+64)
alpha2num = lambda y: ord(y) - ord('A') + 1

print(num2alpha(alpha2num(c) + 1))
# Judge status: Accepted
#!/usr/bin/env python3

from functools import reduce

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = II()
    A = LII()
  
    mn = 10 ** 9
    n = 0
    ans = 0
    for a in A:
        ans += abs(a)
        mn = min(mn, abs(a))
        if a < 0:
            n += 1

    if n % 2 == 0:
        print(ans)
    else:
        print(ans - 2 * mn)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a, b = map(int,input().split())

if a * b > 81:
    print(-1)
else:
    print(a * b)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    N, K = [int(x) for x in input().split()]
    D = [int(x) for x in input().split()]

    Dset = set(D)

    for i in range(N, 1000000):
        for j in str(i):
            if int(j) in Dset:
                break
        else:
            print(i)
            return


    
    
    

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S=input()
N=len(S)
r_S=S[::-1]
c1=int((N-1)/2)
c2=int((N+3)/2)
S1=S[:c1]
r_S1=S1[::-1]
S2=S[(c2-1):]
r_S2=S2[::-1]


#kaibun hantei
if S1==r_S1 and S1==r_S1 and S2==r_S2:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a, b = map(int, input().split())
c = list(map(int, input().split()))
c = sorted(c, reverse=True)
d = 1
ans = 0
for i in c:
    if(d<=b):
        d+=1
    else:ans+=i
    #print(i)
print(ans)
# Judge status: Accepted
S = input()
T = input()

for i, s in enumerate(S):
    if s != T[i]:
        print("No")
        break
else:
    print("Yes")
# Judge status: Accepted
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    X = int(input())

    lcm = X * 360 // math.gcd(X, 360)
    ans = lcm // X
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a, b = map(int, input().split())
print("unsafe" if (a < b) else "safe")
# Judge status: Wrong Answer
from sys import stdin
def main():
    input = stdin.readline

    x = input()

    s = 0
    count = 0
    for cur in x:
        if cur == "S":
            s += 1
        else:
            if s != 0:
                s -= 1
            else:
                count += 2

    print(count)


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

ans=[0]*(n+1)
r=int(n**0.5)+1

for x in range(1,r):
    for y in range(1,r):
        for z in range(1,r):
            t=x**2+y**2+z**2+x*y+y*z+z*x
            if t <= n:
                ans[t]+=1

for i in ans[1:]:
    print(i)
# Judge status: Wrong Answer
s = input()
if s == "ABC":
    print("ARC")
    if s == "ARC":
        print("ABC")
# Judge status: Accepted
S=input()
N=len(S)+1
l=[0]*N
for i in range(N-1):
    if S[i]=="<":
        l[i+1]=l[i]+1
for i in range(N-2,-1,-1):
    if S[i]==">":
        l[i]=max(l[i+1]+1,l[i])
print(sum(l))
# Judge status: Wrong Answer
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))

A_sum = sum(A)

print(N-A_sum)
# Judge status: Wrong Answer
n = int(input())
happy = 0
yesterday = -1
for i in range(n):
    M = 0
    do = list(map(int, input().split()))
    for j in range(3):
        if j != yesterday and M < do[j]:
            M = do[j]
            today = j
        elif j != yesterday and M == do[j]:
            today = -1
    happy += M
    yesterday = today
print(happy)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

list = (0, b - a, c - a)
cnt = 0
for i in list:
    if i == 0:
       cnt += 1

if cnt == 2:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    A, B, T = map(int, input().split())
    print((T // A) * B)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

print(A.count(i+1) for i in range(N))
# Judge status: Wrong Answer

input_line = input()
Line = list(input_line)

flag = 0

for i in Line:
    # print(i)

    if i == "h" and flag == 0:
        flag = 1
    elif i == "i" and flag ==1:
        flag = 0
    else:
        flag = 2
        print("No")

if flag == 1:
    print("No")
elif flag == 0:
    print("Yes")
# Judge status: Accepted
A, B, X = list(map(int,input().split()))
print('YES' if A <= X < A+B else 'NO')
# Judge status: Accepted
from numpy import*
x,y=loadtxt(open(0)).T
print(sum(x*x+y*y<=y[0]**2))
# Judge status: Accepted
L = 10 ** 9
N = int(input())
y = (N - 1) // L + 1
x = (-N) % L
print(0, 0, L, 1, x, y)