Harryxun/stf_run huggingface dataset:
def gcd(a, b):
    mi = min(a, b)
    ma = max(a, b)
    r = ma % mi
    if r == 0:
        return mi
    gcd(mi, r)


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

Sum = sum(A)
s = []
multi = 1.0
for t in A:
    multi = int((multi * t) / gcd(int(multi), int(t)))

for a in A:
    s.append(int(multi / a))

print(multi / sum(s))


### FIXED CODE ###

N = input()
A = list(map(float, input().split()))

print(1 / sum(1 / x for x in A))
n=int(input())
c=list(map(int,input().split()))
c.sort(reverse=True)
res=0
ans=0
mod=10**9+7
p=pow(2,n*2-2,mod)
for i in range(n):
   ans+=(c[i]*(i+2)%mod)*p
prit(ans)

### FIXED CODE ###

n=int(input())
c=list(map(int,input().split()))
c.sort(reverse=True)
res=0
ans=0
mod=10**9+7
p=pow(2,n*2-2,mod)
for i in range(n):
   ans+=(c[i]*(i+2)%mod)*p
print(ans%mod)
n = input()
x = (n-2)*180
print(x)

### FIXED CODE ###

print((int(input())-2)*180)
N = int(input())
S = input()

result = min(S.count("."),S.count("#"))

for i in range(N):
    leftslice = S[:i]
    rightslice = S[i:]
    print(leftslice)
    print(rightslice)
    leftblack = leftslice.count("#")
    rightwhite = rightslice.count(".")
    if result >= leftblack + rightwhite:
        result = leftblack + rightwhite

print(result)

### FIXED CODE ###

N = int(input())
S = input()
 
result = min(S.count("."),S.count("#"))
leftblack = 0
rightwhite = S.count(".")
 
for i in range(N):
    if(S[i] == "."):
        rightwhite -= 1
    else:
        leftblack += 1
    if result >= leftblack + rightwhite:
        result = leftblack + rightwhite
 
print(result)
N = int(input())
conditions = [[] for _ in range(N) ]
for i in range(N):
  a = int(input())
  for _ in range(a):
    x,y = map(int,input().split())
    x -= 1
    conditions[i].append([x,y])

res = 0
for i in range(1<<N):
  mapper = {1: [], 0: []}
  flg = True
  cnt = 0
  for j in range(N):
    if (i>>j)&1:
      for x,y in conditions[j]:
        if x in mapper[1-y] or j in mapper[0]:
          flg = False
          break
        mapper[y].append(x)
      cnt += 1
    else:
      for x,y in conditions[j] or j in mapper[1]:
        if x in mapper[y]:
          flg = False
          break
        mapper[1-y].append(x)

    if not flg: break

  if flg:
    res = max(res, cnt)

print(res)


### FIXED CODE ###

N = int(input())
conditions = [[] for _ in range(N) ]
for i in range(N):
  a = int(input())
  for _ in range(a):
    x,y = map(int,input().split())
    x -= 1
    conditions[i].append([x,y])

res = 0
for i in range(1<<N):
  mapper = {1: [], 0: []}
  flg = True
  cnt = 0
  for j in range(N):
    if (i>>j)&1:
      cnt += 1
      for x,y in conditions[j]:
        if y==1 and not (i>>x)&1:
          flg = False
          break
        elif y==0 and (i>>x)&1:
          flg = False
          break
    if not flg: 
      break

  if flg:
    res = max(res, cnt)

print(res)
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

N, X = map(int, input().split())
a = [abs(int(i)-X) for i in input().split()]
ans = gcd(a[0], a[1])

if N == 1:
    print(abs(X-a[0]))
else:
    for i in range(N):
        ans = gcd(ans, a[i])
    print(ans)

### FIXED CODE ###

def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

N, X = map(int, input().split())
a = [abs(int(i)-X) for i in input().split()]


if N == 1:
    print(a[0])
else:
    ans = gcd(a[0], a[1])
    for i in range(N):
        ans = gcd(ans, a[i])
    print(ans)
if 1<=A<=9:
  if 1<=B<=9:
    print(A*B)
  elif 10<=B<=20:
    print(-1)
elif 10<=A<=20:
  print(-1)

### FIXED CODE ###

A,B=map(int,input().split())
if 1<=A<=9:
        if 1<=B<=9:
            print(A*B)
        else:
            print(-1)
else: print(-1)
n = int(input())
a = list(map(int, input().split()))
b = [0] * pow(10,5)
for i in range(n):
  if a[i] == 0:
    b[0] += 1
    b[1] += 1
  elif a[i] == pow(10,5):
    b[pow(10,5) - 1] += 1
    b[pow(10,5)] += 1
  else:
    b[a[i]] += 1
    b[a[i] - 1] += 1
    b[a[i] + 1] += 1
print(max(b))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0] * (pow(10,5) + 1)
for i in range(n):
  if a[i] == 0:
    b[0] += 1
    b[1] += 1
  elif a[i] == pow(10,5):
    b[pow(10,5) - 1] += 1
    b[pow(10,5)] += 1
  else:
    b[a[i]] += 1
    b[a[i] - 1] += 1
    b[a[i] + 1] += 1
print(max(b))
N, K = map(int, input().split())
S = input()
r = []
l = []
cnt1 = 0
cnt2 = 0

p = 0
if 'L' == S[0]:
    for i in range(N):
        if 'L' == S[i]:
            p += 1
        else:
            ind = i
            if i == N-1:
                print(p-1)
                exit()
            l.append(p)
            break
else:
    for i in range(N):
        if 'R' == S[i]:
            p += 1
        else:
            ind = i
            if i == N-1:
                print(p-1)
                exit()
            r.append(p)
            break

ans = [1]
for i in range(ind, N):
    if S[i] == 'L':
        if cnt2:
            r.append(cnt2)
            ans.append(2)
            cnt2 = 0
        cnt1 += 1
    else:
        if cnt1:
            l.append(cnt1)
            ans.append(2)
            cnt1 = 0
        cnt2 += 1
if cnt1:
    ans.append(1)
else:
    ans.append(1)

ans.sort()
ans.reverse()

sums = 0
for i in range(N-2):
    if 'LL' == S[i:i+2]:
        sums += 1
    elif 'RR' == S[i:i+2]:
        sums += 1
#print(sums)
if K >= len(ans):
    print(len(S) - 1)
else:
    if sums + sum(ans[:K]) >= len(S):
        print(len(S) - 1)
    else:
        print(sums + sum(ans[:K]))


### FIXED CODE ###

N, K = map(int, input().split())
S = input()
cnt1 = 0
cnt2 = 0
if len(S) == 1:
    print(0)
    exit()
p = 0
if 'L' == S[0]:
    for i in range(N):
        if 'L' == S[i]:
            p += 1
        else:
            ind = i
            if i == N-1:
                print(p-1)
                exit()
            break
else:
    for i in range(N):
        if 'R' == S[i]:
            p += 1
        else:
            ind = i
            if i == N-1:
                print(p-1)
                exit()
            break
if p == N:
    ind = N-1
ans = [1]
for i in range(ind, N):
    if S[i] == 'L':
        if cnt2:
            ans.append(2)
            cnt2 = 0
        cnt1 += 1
    else:
        if cnt1:
            ans.append(2)
            cnt1 = 0
        cnt2 += 1
if cnt1:
    ans.append(1)
else:
    ans.append(1)

ans.sort()
ans.reverse()

sums = 0
for i in range(N-1):
    if 'LL' == S[i:i+2]:
        sums += 1
    elif 'RR' == S[i:i+2]:
        sums += 1

if K >= len(ans):
    print(len(S) - 1)
else:
    if len(ans) == 0:
        print(len(S) - 1)
    if sums + sum(ans[:K]) >= len(S):
        print(len(S) - 1)
    else:
        print(sums + sum(ans[:K]))
from functools import reduce
from operator import xor
from math import log

def solve():
  N, K = map(int, input().split())
  X = [int(i) for i in input().split()]
  x = reduce(xor, X)
  maxNum = max(X)
  d = int(log(maxNum, 2))
  D = int(log(K, 2))
  while D > d:
    x |= 1 << D
    D -= 1
  ans = 0
  for a in X:
    ans += a ^ x
  return ans

print(solve())


### FIXED CODE ###

def solve():
  N, K = map(int, input().split())
  A = [int(i) for i in input().split()]
  B = [0] * 40
  for i in range(40):
    for a in A:
      if a & (1 << i): B[i] += 1

  X = 0
  for i in range(39, -1, -1):
    if X + (1 << i) > K: continue
    if B[i] < N - B[i]: X += 1 << i

  ans = 0
  for a in A:
    ans += a ^ X

  return ans

print(solve())
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x*2 > W:
    x = W-x
if y*2 > H:
    y = H-y

a = W*y
b = H*x
if x == 0 or y == 0:
    print(H*W/2, 0)
elif W*y == H*x:
    print(H*W/2, int(W==2*x))
    raise
elif a == b:
    print(a, 1)
elif a > b:
    print(a, 0)
else:
    print(b, 0)


### FIXED CODE ###

W, H, x, y = map(int, input().split())
print(H*W/2, int((2*y == H)&(2*x == W)))
a = int(input())
b = list(map(int,input()))
c = list(map(int,input()))

ans = 0
for i in range(a):
  ans += min(b[i],c[i])
  c[i] -= min(b[i],c[i])
  ans += min(b[i + 1], c[i])

print(ans)
    

### FIXED CODE ###

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

ans = 0
for i in range(a):
  ans += min(b[i],c[i])
  c[i] -= min(b[i],c[i])
  ans += min(b[i + 1], c[i])
  b[i + 1] -= min(b[i + 1], c[i])

print(ans)
# -*- coding: utf-8 -*-
from IPython import embed

class Node():
    def __init__(self, loc=None, left=None, right=None):
        self.loc = loc
        self.l = left
        self.r = right

class Point():
    def __init__(self, id, xy):
        self.id = int(id)
        self.x = int(xy[0])
        self.y = int(xy[1])

if __name__ == '__main__':

    n = int(input())
    P = [Point(i, input().split(" ")) for i in range(n)]
    q = int(input())
    Q = [list(map(int, input().split(" "))) for _ in range(q)]
    T = [None]*n

    np = 0
    def make2DTree(l, r, depth):
        global np
        if l >= r:
            return None
        
        mid = (l+r)//2
        t = np
        np += 1
        if depth%2 == 0:
            P[l:r].sort(key=lambda p:p.x)
        else:
            P[l:r].sort(key=lambda p:p.y)

        T[t] = Node(loc=mid)
        T[t].l = make2DTree(l, mid, depth+1)
        T[t].r = make2DTree(mid+1, r, depth+1)

        return t

    def find(v, sx, tx, sy, ty, depth, ans):
        x = P[T[v].loc].x
        y = P[T[v].loc].y

        if (sx <= x <= tx) and (sy <= y <= ty):
            ans.append(P[T[v].loc].id)

        if depth%2 == 0:
            if T[v].l is not None and sx <= x:
                find(T[v].l, sx, tx, sy, ty, depth+1, ans)
            if T[v].r is not None and x <= tx:
                find(T[v].r, sx, tx, sy, ty, depth+1, ans)

        else:
            if T[v].l is not None and sy <= y:
                find(T[v].l, sx, tx, sy, ty, depth+1, ans)
            if T[v].r is not None and y <= ty:
                find(T[v].r, sx, tx, sy, ty, depth+1, ans)

    root = make2DTree(0, n, 0)
    
    for sx, tx, sy, ty in Q:
        ans = []
        find(root, sx, tx, sy, ty, 0, ans)
        ans.sort()
        print("\n".join(map(str, ans)))
        print("")
    




### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right

if __name__ == '__main__':

    P = [tuple(map(int, input().split())) + (i,)
         for i in range(int(input()))]  # (x,y,i)
    P.sort()
    root = int(math.sqrt(len(P)))
    low = [x for x, y, i in P[::root]]
    high = [x for x, y, i in P[root - 1::root]] + [float('inf')]

    # disjoint subsets (ordered by y) of P
    P = [sorted(P[i:i + root], key=itemgetter(1))
         for i in range(0, len(P), root)]
    P = [([y for x, y, i in Pi], Pi)
         for Pi in P]  # ([y in subsets], [subsets])
    q = int(input())
    Q = [list(map(int, input().split(" "))) for _ in range(q)]

    for sx, tx, sy, ty in Q:
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = P[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <= tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            print('\n'.join(map(str, ret)))
        print()
a = input()
print(a.count('1')


### FIXED CODE ###

a = input()
print(a.count('1'))
n=input()
A={}
for i in range(n):
     x,y=input().split()
     if x=='insert':
         d.add(y)
     else:
         if b in d:
            print('yes')
         else:
            print('no')


### FIXED CODE ###

n=int(input())
A=set()
for i in range(n):
     x,y=input().split()
     if x == 'insert':
         A.add(y)
     else:
         print('yes'*(y in A)or'no')
# -*- coding: utf-8 -*-

def check(string):
    if string[-5:] == "dream":
        new = string[:-5]
        return new

    if string[-7:] == "dreamer":
        new = string[:-7]
        return new

    if string[-5:] == "erase":
        new = string[:-5]
        return new

    if string[-6:] == "eraser":
        new = string[:-6]
        return new

    print("NO")


if __name__ == '__main__':
    s = str(input())

    while s:
        print(s)
        s = check(s)

    if s == "":
        print("YES")


### FIXED CODE ###

# -*- coding: utf-8 -*-

def check(string):
    if string[-5:] == "dream":
        new = string[:-5]
        return new

    if string[-7:] == "dreamer":
        new = string[:-7]
        return new

    if string[-5:] == "erase":
        new = string[:-5]
        return new

    if string[-6:] == "eraser":
        new = string[:-6]
        return new

    print("NO")


if __name__ == '__main__':
    s = str(input())

    while s:
        s = check(s)

    if s == "":
        print("YES")
S = input()
length = len(S)
for c in S:
    if c == 'B':
        countB += 1
soko = 1
ans = 0
for i in range(length):
    if S[-i-1] == 'B':
        ans += i + 1  - soko
        soko += 1
print(ans)

### FIXED CODE ###

S = input()
length = len(S)
countB = 0
for c in S:
    if c == 'B':
        countB += 1
soko = 1
ans = 0
for i in range(length):
    if S[-i-1] == 'B':
        ans += i + 1  - soko
        soko += 1
print(ans)
N0 = int(input())
N1 = list(map,N0)
S_N = 0

for i in range(len(N1)):
    S_N += N1[i]

if N0 % S_N == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N0 = int(input())
N1 = list(map(int,str(N0)))
S_N = 0

for i in range(len(N1)):
    S_N += N1[i]

if N0 % S_N == 0:
    print('Yes')
else:
    print('No')
l=map(int,raw_input().split())
n=raw_input()
ans=chk=0
 
 
def rolling(word,dice):
    if word=='S':
        dice[0],dice[1],dice[5],dice[4]=dice[4],dice[0],dice[1],dice[5]
    elif word=='N':
        dice[0],dice[1],dice[5],dice[4]=dice[1],dice[5],dice[4],dice[0]
    elif word=='W':
        dice[0],dice[2],dice[5],dice[3]=dice[2],dice[5],dice[3],dice[0]
    else:
        dice[0],dice[2],dice[5],dice[3]=dice[3],dice[0],dice[2],dice[5]
    return dice
 
for i in n:
    l=rolling(i,l)
print l[0]


### FIXED CODE ###

class dice:

    def __init__(self, numlist):
        self._men = {"T": numlist[0],
                     "B": numlist[5],
                     "N": numlist[4],
                     "S": numlist[1],
                     "W": numlist[3],
                     "E": numlist[2]}

    def roll(self, direction):
        t = dict(self._men)

        if direction == "N":
            self._men["T"] = t["S"]
            self._men["B"] = t["N"]
            self._men["N"] = t["T"]
            self._men["S"] = t["B"]
        elif direction == "S":
            self._men["T"] = t["N"]
            self._men["B"] = t["S"]
            self._men["S"] = t["T"]
            self._men["N"] = t["B"]
        elif direction == "W":
            self._men["T"] = t["E"]
            self._men["B"] = t["W"]
            self._men["W"] = t["T"]
            self._men["E"] = t["B"]
        elif direction == "E":
            self._men["T"] = t["W"]
            self._men["B"] = t["E"]
            self._men["W"] = t["B"]
            self._men["E"] = t["T"]


    def gettop(self):
        return self._men["T"]

def decode():
    numlist = [int(x) for x in input().split()]
    dlist = input()
    return numlist, dlist

if __name__ == '__main__':

    numlist, dlist = decode()
    d1 = dice(numlist)
    for c in dlist:
        d1.roll(c)
    print(d1.gettop())
import math
a, b, k =map(int, input().split())
gcd = math.gcd(a,b)
divesor_list = []
if gcd == 1:
    divesor_list = [gcd]
else:
    for i in range(gcd, 0, -1):
        if gcd % i == 0:
            divesor_list.append(i)
print(divesor_list[k-1])

### FIXED CODE ###

import math
a, b, k =map(int, input().split())
divesor_list = []
c = min(a, b)
if c == 1:
    divesor_list = [1]
else:
    for i in range(c, 0, -1):
            if (a % i == 0) & (b % i == 0):
                divesor_list.append(i)
print(divesor_list[k-1])
from collections import deque
n, m = [int(i) for i in input().split()]
rutes = [[]] * n
visited = [0] + [-1] * (n-1)
q = deque([0])

for i in range(n):
    a, b = [int(i) for i in input().split()]
    rutes[a-1].append(b)
    rutes[b-1].append(a)

cnt = 0
def visit(x):
    for i in rutes[x-1]:
        if visited[i] == -1:
            q.append(i)
            visited[i-1] = visited[x-1] + 1

while len(q) > 0:
    tmp = q.pop()
    visit(tmp)

for i in range(2,n+1):
    print(visited[i-1])

### FIXED CODE ###

from collections import deque
n, m = [int(i) for i in input().split()]
rooms = [[] for i in range(n)]
dist = [-1] * n
for i in range(m):
    a, b = [int(i) for i in input().split()]
    rooms[a-1].append(b)
    rooms[b-1].append(a)

que = deque()
que.append(1)
dist[0] = 0
ans = [0] * n
while(len(que) != 0):
    v = que.popleft()
    for i in rooms[v-1]:
        if dist[i-1] == -1:
            dist[i-1] = dist[v-1] + 1
            que.append(i)
            ans[i-1] = v
print("Yes")
for i in ans[1:]:
    print(i)
a = list(map(int, input().split())
a += list(map(int, input().split())
a += list(map(int, input().split())
A = []
N = int(input())
b = list(int(input()) for i in range(N))

for i in range(9):
    if a[i] in b[i]:
        A[i] = "maru"

if A[0] == A[1] == A[2] or A[3] == A[4] == A[5] or A[6] == A[7] == A[8] or A[2] == A[4] == A[6]:
    print("yes")
elif A[0] == A[3] == A[6] or A[1] == A[4] == A[7] or A[2] == A[5] == A[8]:
    print("yes")
else:
    print("no")  

### FIXED CODE ###

import math
N = int(input())

if N == 1:
    print(N)
elif N%2 == 0:
    print(math.floor(N/2))
else:
    print(math.floor(N/2)+ 1)
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for ans in range(10**n):
    ans = str(ans)
    if len(ans) == n and all([ans[s[j]-1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()
print(-1)

### FIXED CODE ###

# n,m = map(int, input().split())
# sc = [map(int, input().split()) for _ in range(m)]
# s, c = [list(i) for i in zip(*sc)]
#
#
#
# for i in range(10**n):
#     ans = str(i)
#     if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
#         print(ans)
#         exit()
#
#
# print(-1)

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

s, c = [], []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)

for i in range(10 ** n):
    ans = str(i)
    if len(ans) == n and all([ans[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()

print(-1)
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(m):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)

### FIXED CODE ###

n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(n):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)
n = int(input())
num = 0
for num in range(n+1):
  total = total + num
print(total)


### FIXED CODE ###

n = int(input())
total = 0
for num in range(n+1):
  total = total + num
print(total)
n = int(input())
s = input()
if n % 2 == 0:
  if (s[:n // 2] == s[n // 2:]) print(Yes)
  else print(No)
else print(No)
  

### FIXED CODE ###

n = int(input())
s = input()
if (s[:n // 2] == s[n // 2:]): print("Yes")
else: print("No")
r = float(input())
print '%f %f' % (math.pi, math.pi)

### FIXED CODE ###

import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)
n=int(input())
s=[]
for i in range(N):
  s.append(input())
  
print(len(set(s)))  

### FIXED CODE ###

n=int(input())
s=[]
for i in range(n):
  s.append(input())
  
print(len(set(s)))
'''input
123
123
123
123
123
'''

a=[]

for i in range(5):
	a.append(int(input()))
# print(a)
flag=[]

for i in range(5):
	if a[i]%10!=0:
		flag.append(a[i]%10)
	else:
		flag.append(-1)
# print(flag)

endInd=float('inf')
end=float('inf')

for i in range(5):
	if flag[i]>0 and end>flag[i]:
		end=flag[i]
		endInd=i
# print(a[endInd])

if endInd=='inf':
	print(sum(a))
else:
	s=a[endInd]
	# print(s)
	a.pop(endInd)
	flag.pop(endInd)
	# print(a)
	for i in range(4):
		if flag[i]>0:
			a[i]=(a[i]//10+1)*10
	# print(a)
	s+=sum(a)
	print(s)


### FIXED CODE ###

'''input
101
86
119
108
57
'''

a=[]

for i in range(5):
	a.append(int(input()))
# print(a)
flag=[]

for i in range(5):
	if a[i]%10!=0:
		flag.append(a[i]%10)
	else:
		flag.append(-1)
# print(flag)

endInd=-1
end=float('inf')

for i in range(5):
	if flag[i]>0 and end>flag[i]:
		end=flag[i]
		endInd=i
# print(a[endInd])

if endInd==-1:
	print(sum(a))
else:
	s=a[endInd]
	# print(s)
	a.pop(endInd)
	flag.pop(endInd)
	# print(a)
	for i in range(4):
		if flag[i]>0:
			a[i]=(a[i]//10+1)*10
	# print(a)
	s+=sum(a)
	print(s)
a_list = list(input())
#print(a_list)
b_list = list(input())
#print(b_list)
c_list = list(input())
#print(c_list)
x=a_list.pop(0)
while True:
    if x=="a":
        x = a_list.pop(0)
    elif x == "b":
        x = b_list.pop(0)
    else:
        x = c_list.pop(0)
    if len(a_list)==0:
        print("A")
        break
    elif len(b_list)==0:
        print("B")
        break
    elif len(c_list):
        print("C")
        break

### FIXED CODE ###

a_list = list(input())
b_list = list(input())
c_list = list(input())
x=a_list.pop(0)
while True:
    if x=="a":
        if len(a_list)==0:
            print("A")
            break
        else:
            x = a_list.pop(0)
    elif x == "b":
        if len(b_list)==0:
            print("B")
            break
        else:
            x = b_list.pop(0)
    else:
        if len(c_list)==0:
            print("C")
            break
        else:
            x = c_list.pop(0)
elif N != 1 and M == 1:
    print(N - 2)
elif N >= 2 and M >= 2:
    print((N - 2) * (M - 2))


#A = [[0] * W for i in range(H)]
#C = ["o" * W for i in range(H)] 
#C = ["#"*(W+2)] + ["#"+C[i]+"#" for i in range(H)] + ["#"*(W+2)]
#dx = [1, 1, 0, -1, -1, -1, 0, 1]
#dy = [0, 1, 1, 1, 0, -1, -1, -1]
#
#for h in range(H):
#    for w in range(W):
#        for i in range(8):
#            if C[h+1+dx[i]][w+1+dy[i]] == "o":
#                A[h][w] += 1
#ans = 0
#for h in range(H):
#    for w in range(W):
#        if A[h][w] % 2 == 0:
#            ans += 1
#
#print(ans)


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))


#A = [[0] * W for i in range(H)]
#C = ["o" * W for i in range(H)] 
#C = ["#"*(W+2)] + ["#"+C[i]+"#" for i in range(H)] + ["#"*(W+2)]
#dx = [1, 1, 0, -1, -1, -1, 0, 1]
#dy = [0, 1, 1, 1, 0, -1, -1, -1]
#
#for h in range(H):
#    for w in range(W):
#        for i in range(8):
#            if C[h+1+dx[i]][w+1+dy[i]] == "o":
#                A[h][w] += 1
#ans = 0
#for h in range(H):
#    for w in range(W):
#        if A[h][w] % 2 == 0:
#            ans += 1
#
#print(ans)
A = input() B = input()
C = A *B
print(C)

### FIXED CODE ###

a , b = input() . split()
c = int(a) *int(b)
print(c)
x=input()
result = x*x
print(result)


### FIXED CODE ###

x=int(input())
result = x**3
print(result)
a = list(map(int,input().split())).sorted()
print(a[0]*a[1]/2)


### FIXED CODE ###

a = sorted(list(map(int,input().split())))
print(int(a[0]*a[1]/2))