Harryxun/stf_run huggingface dataset:
r, c = map(int, input().split())
a = [[int(num) for num in input().split()] for i in range(r)]
a.append([0, 0, 0, 0, 0])
for i in range(c):
    for j in range(r):
        a[r][i] += a[j][i]
for i in range(c):
    a[i].append(sum(a[i]))
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print(a[i][j])
        else:
            print(a[i][j], end=" ")

### FIXED CODE ###

r, c = map(int, input().split())
a = [[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
    j = 0
    for line in input().split():
        a[i][j] = int(line)
        a[i][c] += a[i][j]
        j += 1
for i in range(c+1):
    for j in range(r):
        a[r][i] += a[j][i]
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print(a[i][j])
        else:
            print(a[i][j], end=" ")
r=[int(x) for x in input().split()]
print(float(r**2*math.pi),float(2*r*math.pi))


### FIXED CODE ###

from math import pi
r = float(input())
print("{:.010f} {:.010f}".format(r * r * pi, 2 * pi * r))
def solve():
  H, W, M = map(int, input().split())
  bomb = [[0]*W for _ in range(H)]
  lis_h = [0]*H
  lis_w = [0]*W
  for i in range(M):
    h,w = map(int, input().split())
    bomb[h-1][w-1] = 1
    lis_h[h-1] += 1
    lis_w[w-1] += 1
  ans = 0
  for h in range(H):
    for w in range(W):
      ans = max(ans, lis_h[h]+lis_w[w]-bomb[h][w])
  return ans
print(solve())

### FIXED CODE ###

from collections import defaultdict
def solve():
  H, W, M = map(int, input().split())
  bomb = defaultdict(lambda: 0)
  lis_h = [0]*H
  lis_w = [0]*W
  for _ in range(M):
    h,w = map(int, input().split())
    h -= 1
    w -= 1
    bomb[(h,w)] = 1
    lis_h[h] += 1
    lis_w[w] += 1
  m_h = max(lis_h)
  m_w = max(lis_w)
  m_h_lis = []
  m_w_lis = []
  for i in range(H):
    if lis_h[i]==m_h:
      m_h_lis.append(i)
  for i in range(W):
    if lis_w[i]==m_w:
      m_w_lis.append(i)
  ans = 0
  for h in m_h_lis:
    for w in m_w_lis:
      if bomb[(h,w)]==0:
        return m_h+m_w
  return m_h+m_w-1
print(solve())
#082_D
s = input()
x, y = map(int, input().split())
xgo, ygo = [], []

flg = True
cnt = 0
for i in range(len(s)):
    if s[i] == 'T':
        if flg and cnt > 0:
            xgo.append(cnt)
        elif cnt > 0:
            ygo.append(cnt)
        flg = (flg + 1) % 2
        cnt = 0
    else:
        cnt += 1
        
if flg and cnt > 0:
    xgo.append(cnt)
elif cnt > 0:
    ygo.append(cnt)
    
def search(L, x, flg):
    s = sum(L)
    dp = [[False for _ in range(s*2+1)] for _ in range(len(L)+1)]
    dp[0][s + 1] = True
    
    for i in range(1, len(L)+1):
        for j in range(-s, s+1):
            k = j + s
            if dp[i-1][k-L[i-1]]:
                dp[i][k] = True
            if dp[i-1][k+L[i-1]]:
                if flg and i == 1:
                    continue
                else:
                    dp[i][k] = True

    return dp[len(L)][s+x]

print('Yes' if search(xgo, x, True) and search(ygo, y, False) else 'No')

### FIXED CODE ###

#082_D
s = input()
x, y = map(int, input().split())
xgo, ygo = [], []

cnt = 0
flg = True
check = True if s[0] == 'F' else False
for i in range(len(s)):
    if s[i] == 'T':
        if flg and cnt > 0:
            xgo.append(cnt)
        elif cnt > 0:
            ygo.append(cnt)
        cnt = 0
        flg = (flg + 1) % 2
    else:
        cnt += 1

if flg and cnt > 0:
    xgo.append(cnt)
elif cnt > 0:
    ygo.append(cnt)

flg1, flg2 = len(xgo)==0, len(ygo)==0

sum_x, sum_y = sum(xgo), sum(ygo)
dp1 = [[False for _ in range(2*sum_x+1)] for _ in range(len(xgo)+1)]
dp2 = [[False for _ in range(2*sum_y+1)] for _ in range(len(ygo)+1)]

if check:
    dp1[1][sum_x+xgo[0]] = True
    for i in range(2, len(xgo)+1):
        for j in range(-sum_x, sum_x+1):
            if 0 <= j+sum_x-xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x-xgo[i-1]]:
                    dp1[i][j+sum_x] = True
            if 0 <= j+sum_x+xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x+xgo[i-1]]:
                    dp1[i][j+sum_x] = True
else:
    dp1[0][sum_x] = True
    for i in range(1, len(xgo)+1):
        for j in range(-sum_x, sum_x+1):
            if 0 <= j+sum_x-xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x-xgo[i-1]]:
                    dp1[i][j+sum_x] = True
            if 0 <= j+sum_x+xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x+xgo[i-1]]:
                    dp1[i][j+sum_x] = True

dp2[0][sum_y] = True
for i in range(1, len(ygo)+1):
    for j in range(-sum_y, sum_y+1):
        if 0 <= j+sum_y-ygo[i-1] <= 2*sum_y:
            if dp2[i-1][j+sum_y-ygo[i-1]]:
                dp2[i][j+sum_y] = True
        if 0 <= j+sum_y+ygo[i-1] <= 2*sum_y:
            if dp2[i-1][j+sum_y+ygo[i-1]]:
                dp2[i][j+sum_y] = True
                
if flg1:
    flgx = (x == 0)
elif abs(x) > sum_x:
    flgx = False
else:
    flgx = dp1[len(xgo)][sum_x+x]
    
if flg2:
    flgy = (y == 0)
elif abs(y) >sum_y:
    flgy = False
else:
    flgy = dp2[len(ygo)][sum_y+y]
    
print('Yes' if flgx and flgy else 'No')
あ

### FIXED CODE ###

N = int(input())
a = list()
for i in range(N):
	a.append(int(input()))

temp = 1
count = 0
while temp != 2 and count <= 100001:
	temp = a[temp - 1]
	count += 1

if count > 100000:
	print(-1)
else:
	print(count)
info = [int(n) for n in input().split()]

group = info[1] + info[2]

a = info // group
b = info % group
if b > info[1]:
    b = info[1]


result = a * info[1] + b
print(result)

### FIXED CODE ###

info = [int(n) for n in input().split()]

group = info[1] + info[2]

a = info[0] // group
b = info[0] % group
if b > info[1]:
    b = info[1]


result = a * info[1] + b
print(result)
n = int(input())
s = input()

ans = 0
while s.find('#.') != -1:
    pos = s.find('#.')
    if s[pos-1] == '#':
        s = s[:pos] + '##' + s[pos+2:]
    elif s[pos+2] == '.':
        s = s[:pos] + '..' + s[pos+2:]
    elif s[pos-2:pos] == '#.':
        s = s[:pos] + '##' + s[pos+2:]
    elif s[pos+2:pos+4] == '#.':
        s = s[:pos] + '..' + s[pos+2:]
    else:
        s = s[:pos] + '##' + s[pos+2:]
    ans += 1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10**9

cta = 0
ctb = 0
a = [0]*n
b = [0]*n
for i in range(n):
    if s[i] == '.':
        cta += 1
    else:
        ctb += 1
    a[i] = cta
    b[i] = ctb
for i in range(n):
    res = min(res,b[i]+a[-1]-a[i])
res = min(res,a[-1],b[-1])
print(res)
M, N = map(int, raw_input().split())
K = input()

d = {}

for i in range(M):
    a = raw_input()
    for j in range(N):
        d[i+1, j+1] = a[j]

for _ in range(K):
    b = map(int, raw_input().split())
    D = {}
    D['J'] = D['O'] = D['I'] = 0
    for i in range(b[0], b[2]+1):
        for j in range(b[1], b[3]+1):
            D[d[i, j]] += 1
    print D['J'], D['O'], D['I']

### FIXED CODE ###

from array import array

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

D0 = [array('l', [0]) * (N+1) for _ in xrange(M+1)]
D1 = [array('l', [0]) * (N+1) for _ in xrange(M+1)]

for i in xrange(1, M+1):
    a = raw_input()
    for j in xrange(1, N+1):
        D0[i][j] = D0[i-1][j] + D0[i][j-1] - D0[i-1][j-1] + (a[j-1] == 'J')
        D1[i][j] = D1[i-1][j] + D1[i][j-1] - D1[i-1][j-1] + (a[j-1] == 'O')

for _ in xrange(K):
    b0, b1, b2, b3 = map(int, raw_input().split())
    nJ = D0[b2][b3]-D0[b0-1][b3]-D0[b2][b1-1]+D0[b0-1][b1-1]
    nO = D1[b2][b3]-D1[b0-1][b3]-D1[b2][b1-1]+D1[b0-1][b1-1]
    nI = (b2-b0+1)*(b3-b1+1)-nJ-nO
    print nJ, nO, nI
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math

N = int(input())
T = [0 for i in range(N)]
for i in range(N):
    T[i] = int(input())

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

ans = 1
for t in T:
    ans = lcm(ans,t)

print(ans)


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions

N = int(input())
T = [int(input()) for i in range(N)]


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

ans = 1
for t in T:
    ans = lcm(ans,t)

print(ans)
N = int(input())
S = list(input())

count = 0
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
        count += 1

print(count)



### FIXED CODE ###

N = int(input())
S = list(input())

count = 0

if N >= 3:
    for i in range(N - 1):
        if (i + 2) < N and S[i] == 'A' and S[i + 1] == 'B' and S[i + 2] == 'C':
           count += 1
    print(count)
else:
    print(0)
S = input()

S = S.replace("eraser","")
S = S.replace("erase","")
S = S.replace("dreamer","")
S = S.replace("dream","")

if len(S) == 0:
    print("YES")
else:
    print("NO")

print(ans)


### FIXED CODE ###

S = input()
S = S.replace('eraser', '')
S = S.replace('erase', '')
S = S.replace('dreamer', '')
S = S.replace('dream', '')
if len(S) == 0:
    print('YES')
else:
    print('NO')
h,w=map(int,input().split())
print("#"*(w+2))
for i in range(h):
  d=input()
  d.insert("#",0)
  d.append("#")
  print(d)
print("#"*(w+2))

### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
print("#"*(w+2))
for i in range(h):
  d=input()
  print("#"+d+"#")
print("#"*(w+2))
N = int(input())
nums = list(map(int, input().split()))
count = 0
max_count = []
right = 0
while True:
    if nums[right+1] <= nums[right]:
        count += 1    
    else:
        max_count.append(count)
        count = 0
        
    right += 1
    if right == N-1:
        break
    
print(max(max_count))

### FIXED CODE ###

N = int(input())
nums = list(map(int, input().split()))
count = 0
max_count = 0
right = 0
while True:
    if right == N-1:
        break
    
    if nums[right+1] <= nums[right]:
        count += 1    
    else:
        count = 0
        
    if max_count < count:
        max_count = count
        
    right += 1
    
print(max_count)
t,x=map(int(),input().split())
print(t/x)

### FIXED CODE ###

t,x=map(int,input().split())
print(t/x)
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    import numpy as np

    N, M = list(map(int, input().split()))
    s = np.zeros([N, M], dtype=int)

    for i in range(N):
        for j in range(M):
            for dx in range(-1, 2):
                for dy in range(-1, 2):
                    if (0 <= i + dy < N) and (0 <= j + dx < M):
                        if s[i][j] == 0:
                            s[i][j] = 1
                        else:
                            s[i][j] = 0

    print(np.sum(s))


### FIXED CODE ###

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    N, M = list(map(int, input().split()))

    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))
import math
from functools import lru_cache
def Frog1():
    n = int(input())
    h = list(map(int,input().split(' ')))
    @lru_cache(None)
    def Solve(i):
        if i==n-1:
            return 0
        if i==n-2:
            return Solve(i+1)+abs(h[i]-h[i+1])
        return min(Solve(i+1)+abs(h[i]-h[i+1]),Solve(i+2)+abs(h[i]-h[i+2]))
    return Solve(0)

print(Frog1())



### FIXED CODE ###

import math
n = int(input())
h = list(map(int,input().split(' ')))
'''
n-=1
inf = int(1e9+5)

dp = {}
def frog1(i):
    if i==n:
        return 0
    if i in dp:
        return dp[i]
    
    a = 0
    b = 0
    if i+1>n:
        a = inf
    else:
        a = frog1(i+1)+abs(h[i]-h[i+1])

    if i+2>n:
        b = inf
    else:
        b = frog1(i+2)+abs(h[i]-h[i+2])
    dp[i] = min(a,b)
    return dp[i]
'''
def solve(n,h):
    dp = [0]*n
    for i in reversed(range(0,n-1)):
        if i==n-1:
            dp[i] = 0
        else:
            if i==n-2:
                dp[i] = abs(h[n-1]-h[n-2])
                continue
            a = 0
            b = 0
            if i+1<=n-1:
                a = dp[i+1]+abs(h[i]-h[i+1])
            if i+2<=n-1:
                b = dp[i+2]+abs(h[i]-h[i+2])  
            dp[i] = min(a,b)
    return dp[0]
print(solve(n,h))
S=list(set(input()))
S.sort()
import string
A=string.ascii_lowercase
for i in range(len(A)):
    if not S[i]==A[i]:
        print(A[i])
        break


### FIXED CODE ###

S=list(set(input()))
S.sort()
import string
switch=True
A=list(string.ascii_lowercase)
for i in A:
    if not i in S:
        print(i)
        switch=False
        break
if switch:
    print("None")
N,K=map(int,input().split())
c=[0,0,0]
for i in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))

### FIXED CODE ###

N,K=map(int,input().split())
c=[0]*N
for _ in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))
#

import sys
input=sys.stdin.readline
MOD=10**9+7


def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    if N==1:
        print(A[0])
        exit()
    A.sort()
    A2n=[]
    for i in range(0,N,2):
        if A[i]<=0 and A[i+1]<=0:
            A2n.append(A[i]*A[i+1])
        else:
            break

    A.sort(reverse=True)
    ans=1
    if A[0]<=0 and K%2==1:
        for i in range(K):
            ans=(ans*A[i])%MOD
        print(ans)
        exit()
    ni=0
    i=0
    while(K>0):
        if len(A2n)-ni>0 and A[i]*A[i+1]<A2n[ni] and K>=2:
            ans=(ans*A2n[ni])%MOD
            K-=2
            ni+=1
        else:
            ans=(ans*A[i])%MOD
            i+=1
            K-=1
    print(ans)
            
    
    
if __name__=="__main__":
    main()


### FIXED CODE ###

#

import sys
input=sys.stdin.readline
MOD=10**9+7


def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    if N==1:
        print(A[0])
        exit()
    A.sort()
    A2n=[]
    for i in range(0,N,2):
        if i+1>=N:
            break
        if A[i]<=0 and A[i+1]<=0:
            A2n.append(A[i]*A[i+1])
        else:
            break

    A.sort(reverse=True)
    ans=1
    if A[0]<=0 and K%2==1:
        for i in range(K):
            ans=(ans*A[i])%MOD
        print(ans)
        exit()
    ni=0
    i=0
    while(K>0):
        if i+1<N and len(A2n)-ni>0 and A[i]*A[i+1]<A2n[ni] and K>=2:
                ans=(ans*A2n[ni])%MOD
                K-=2
                ni+=1
        else:
            ans=(ans*A[i])%MOD
            i+=1
            K-=1
    print(ans)
            
    
    
if __name__=="__main__":
    main()
s,t=input().split()
a,b=map(int.input().split())
u=input()
print(a-1,b) if s==u else print(a,b-1)

### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u=input()
print(a-1,b) if s==u else print(a,b-1)
#abc176-e
import sys
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))

point_bom = [[0]*(W+1) for _ in range(H+1)]
for _ in range(M):
    h,w = map(int,input().split())
    point_bom[h][w]=1
#point_bom = np.array(point_bom)
#row_bom = point_bom.sum(axis=0)
#col_bom = point_bom.sum(axis=1)
row_bom = []
for rb in point_bom:
    row_bom.append(sum(rb))
col_bom = [sum(x) for x in zip(*point_bom)]
    
max_row = max(row_bom)
max_col = max(col_bom)

ind_max_row =[]
ind_max_col = []

for i in range(len(row_bom)):
    if row_bom[i] == max_row:
         ind_max_row.append(i)
for i in range(len(col_bom)):
    if col_bom[i] == max_col:
        ind_max_col.append(i)

flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
for mr in ind_max_row:
    for mc in ind_max_col:
        if point_bom[mc][mr] == 0:
            flag = 0
            break
    if flag == 0:
        break
print(max_row+max_col - flag)
        
        


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))
list = [T,S]
	setup.strip','
list

### FIXED CODE ###

A, B = input().split()
C = B + A
print(C)
INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2
d = [INFTY for i in range(n)]
p = [-1 for i in range(n)]
color = [WHITE for i in range(n)]

n = int(input())
M = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
    for j in range(n):
        if (M[i][j] == -1):
            M[i][j] = INFTY

def prim():
    global M, d, p, color
    d[0] = 0
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if (d[v] > M[u][v]):
                    d[v] = M[u][v]
                    p[v] = u
                    color[v] = GRAY
    
    return sum([M[i][p[i]] for i in range(n) if p[i] != -1])

print(prim())

### FIXED CODE ###

INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2

n = int(input())
M = [list(map(int, input().split())) for i in range(n)]

d = [INFTY for i in range(n)]
p = [-1 for i in range(n)]
color = [WHITE for i in range(n)]

for i in range(n):
    for j in range(n):
        if (M[i][j] == -1):
            M[i][j] = INFTY

def prim():
    global M, d, p, color
    d[0] = 0
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if (d[v] > M[u][v]):
                    d[v] = M[u][v]
                    p[v] = u
                    color[v] = GRAY
    
    return sum([M[i][p[i]] for i in range(n) if p[i] != -1])

print(prim())
n = int(input())
s = input()
l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(0,len(s)):
  for j in range (0,26):
    if s[i] == l[j]:
      s[i] = l[(j+n)%26]
      break
print(s)

### FIXED CODE ###

n = int(input())
s = input()
s = list(s)
l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(0,len(s)):
  for j in range (0,26):
    if s[i] == l[j]:
      s[i] = l[(j+n)%26]
      break
s = ''.join(s)
print(s)
N = int(input())
 S = [int(input()) for i in range(N)]

 ans = sum(S)
 S.sort()

 for s in S:
   if ans%10 == 0 and s%10 != 0:
     ans = ans - s
     break

 if ans%10 != 0:
   print(ans)
 else:
   print(0)


### FIXED CODE ###

N = int(input())
S = [int(input()) for i in range(N)]

ans = sum(S)
S.sort()

for s in S:
  if ans%10 == 0 and s%10 != 0:
    ans = ans - s
    break

if ans%10 != 0:
  print(ans)
else:
  print(0)
li = list(map(int,input().split()))
for i, j in enumerate(li):
  if j == 0:
    echo i + 1

### FIXED CODE ###

li = list(map(int,input().split()))
for i, j in enumerate(li):
  if j == 0:
    print(i + 1)
N = int(input())
b = input().split(" ")

for i in range(N):
    X = b
    X.pop(i)
    X.sort()
    print(X[len(X)//2])

### FIXED CODE ###

N = int(input())
b = [int(i) for i in input().split()]
c = sorted(b[:])
s = c[(N-1)//2]
l = c[N//2]

for i in b:
    if i > s:
       print(s)
    else:
       print(l)
from scipy.misc import comb
N,M = map(int,input().split())
even = int(comb(N,2))
odd = int(comb(M,2))
print(even + odd)

### FIXED CODE ###

S = [c for c in input()]
N = len(S) - 1
s1 = S[:(N-1)//2 + 1]
s2 = S[(N+3)//2:]

rs = list(reversed(S))
rs1 = list(reversed(s1))
rs2 = list(reversed(s2))
if S == rs and s1 == rs1 and s2 == rs2:
    print("Yes")
else:
    print("No")
suuzi = int(input())

if a < 1000:
    print("ABC")
else:
    print("ABD")

### FIXED CODE ###

suuzi = int(raw_input())
 
if suuzi <= 999:
	print("ABC")
elif suuzi >= 1000:
	print("ABD")
x,y,z,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans=[]
for i in range(x):
  for j in range(y):
    for k in range(z):
      if (i+1)*(j+1)*(k+1)<=K:
        ans.append(a[i]+b[j]+c[k])
      else:
        break
ans.sort(reverse=True)
for i in range(K):
  print(ans[i])

### FIXED CODE ###

s = []
for i in range(5):
    s.append(int(input()))
k = int(input())
flag = True
for x in s:
    for y in s:
        if x != y:
            z = x - y
            if z <= k:
                pass
            else:
                flag = False
if flag:
    print('Yay!')
else:
    print(':(')
N = int(input())
A = list(map(int,input().split()))
A.sort()
d = {}
n = A[-1]
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    i = 0
    for j in A:
        if i == j:
            d[i] = 1
        i = j
        if i > 10**3:
            break
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime
P = makePrimeChecker(n)
i = 0
ans = 0
for j in A:
    if i == j:
        continue
    else:
        i = j
        if P[i]:
            if d[i] == 0:
                ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
d = {}
n = A[-1]
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    i = 0
    for j in A:
        if i == j:
            isPrime[i] = False
            continue
        i = j
        if isPrime[i]:
            for j in range(i * 2, n + 1, i):
                isPrime[j] = False
    return isPrime
P = makePrimeChecker(n)
i = 0
ans = 0
for j in A:
    if i == j:
        continue
    else:
        i = j
        if P[i]:
            ans += 1
print(ans)
s = str(input())

print(s[1]+s[2]+s[3])


### FIXED CODE ###

s = str(input())

print(s[0]+s[1]+s[2])
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect

    s = input()
    t = input()
    n = len(s)
    m = len(t)
    alpha = [[] for _ in range(26)]

    # KeyInsight
    # 部分列判定：場所i以降で文字Cが最初に現れる位置を高速に求める
    # アルファベットの出現位置をリストで記録

    # sで各文字が出現する位置を2周分記録
    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index)

    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index + n)

    ans = 1
    p = 0

    for ti in t:
        c = ord(ti) - ord('a')

        if len(alpha[c]) == 0:
            print('-1')
            exit()

        p = alpha[c][bisect(alpha[c], p)]

        if p > n:
            p -= n
            ans += n

    ans += p

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

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


def main():
    from bisect import bisect_left

    s = input()
    t = input()
    n = len(s)
    m = len(t)
    alpha = [[] for _ in range(26)]

    # KeyInsight
    # 部分列判定：場所i以降で文字Cが最初に現れる位置を高速に求める
    # アルファベットの出現位置をリストで記録

    # sで各文字が出現する位置を2周分記録
    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index)

    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index + n)

    ans = 0
    p = 0

    for ti in t:
        c = ord(ti) - ord('a')

        if len(alpha[c]) == 0:
            print('-1')
            exit()

        pi = bisect_left(alpha[c], p)
        p = alpha[c][pi]
        p += 1

        if p >= n:
            p -= n
            ans += n

    ans += p

    print(ans)


if __name__ == '__main__':
    main()
N = int(input(""))
    A = list(map(int, input("").split()))
     
    limit = 1000000000000000000
     
    result = 1
    for i in A:
      if result >= limit:
        result = -1
        break
      result = result * i
     
    print(result)

### FIXED CODE ###

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

limit = 1000000000000000000

result = 1
if 0 not in A:
  for i in A:
    result = result * i
    if result > limit:
      result = -1
      break
else:
  result = 0

print(result)