Harryxun/stf_run huggingface dataset:
while True:
	try:
		x=[[int(i) for i in input()] for j in range(8)]
		count=0
		num=[]
		for i in range(8):
			if x[i].count(1)!=0:
				num.append(i)
				count+=1
		if count==1:
			print("C")
		elif count==4:
			print("B")
		elif count==2:
			for j in range(8):
				if x[num[0]][j]==1:
					if j==0:
						if x[num[0]+1][j]==1:
							print("A")
						else:
							print("E")
					else:
						if x[num[0]+1][j-1]==1:
							print("G")
						else:
							if x[num[0]+1][j]==1:
								print("A")
							else:
								print("E")
					break
		else:
			for j in range(8):
				if x[num[0]][j]==1:
					if j==0:
						print("F")
					else:
						if x[num[0]][j-1]==1:
							print("D")
						else:
							print("F")
					break
			
	except EOFError:
		break


### FIXED CODE ###

while True:
	try:
		x=[[int(i) for i in input()] for j in range(8)]
		count=0
		num=[]
		for i in range(8):
			if x[i].count(1)!=0:
				num.append(i)
				count+=1
		if count==1:
			print("C")
		elif count==4:
			print("B")
		elif count==2:
			for j in range(8):
				if x[num[0]][j]==1:
					if j==0:
						if x[num[0]+1][j]==1:
							print("A")
						else:
							print("E")
					else:
						if x[num[0]+1][j-1]==1:
							print("G")
						else:
							if x[num[0]+1][j]==1:
								print("A")
							else:
								print("E")
					break
		else:
			for j in range(8):
				if x[num[0]][j]==1:
					if j==0:
						print("F")
					else:
						if x[num[0]+1][j-1]==1:
							print("D")
						else:
							print("F")
					break
		input()
	except EOFError:
		break
_n = int(sys.stdin.readline())

    # N! = aH + b
    # (N+1) * N! = aH(N+1) + b(N+1)
    #            = aH(N+1) + int(b(N+1)/H) * H + b(N+1) % H
    result = reduce(lambda a, n: (a * n) % H, range(1, _n + 1), 1)

    print(result)


### FIXED CODE ###

""" abc055_b """

import sys
from functools import reduce

H = pow(10, 9) + 7

def _main():
    _n = int(sys.stdin.readline())

    # N! = aH + b
    # (N+1) * N! = aH(N+1) + b(N+1)
    #            = aH(N+1) + int(b(N+1)/H) * H + b(N+1) % H
    result = reduce(lambda a, n: (a * n) % H, range(1, _n + 1), 1)

    print(result)

if __name__ == '__main__':
    _main()
#106_C
S=input()
K=int(input())
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print(1 if K<=ans else S[ans])

### FIXED CODE ###

#106_C
S=input()
K=int(input())
ans=0
for i in range(len(S)):
    if S[i]!='1':
        ans=i
        break

print('1' if K<=ans else S[ans])
N,M = map(int,input().split(' '))
l = [int(input()) for i in range(M)]

pre = 0
last = -1
ans_l = []
flag = False
l.append(N+1)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in l:
    if i==1:
        last = 1
        continue
    if i-last==1:
        flag =True
        break
    n = i - last - 3
    r = 0
    tmp = 1
    dif = 1
    while dif>0:
        r += 1
        if n<=0 or n<r:
            break
        tmp += cmb(n, r)
        dif = n-r
        n -= 1
    ans_l.append(tmp)
    # print(i,ans_l)
    last = i
if flag:
    print(0)
else:
    ans = 1
    for i in ans_l:
        ans*=i
    print(ans%1000000007)

### FIXED CODE ###

N,M = map(int,input().split(' '))
l = set([int(input()) for i in range(M)])

mod = 10**9+7
dp = {}
for i in range(N+1):
    dp[i] = 1
dp[1] = 0 if 1 in l else 1

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

print(dp[N]%mod)
k = int(input())
s = input()
n = len(s)

if n <= k 
print(s)

if n >= k
print(s[:k]+'...')

### FIXED CODE ###

k = int(input())
s = input()
n = len(s)
     
if n <= k:
	print(s)
else:
	print(s[:k] + '...')
S = input('天気が雨である日が連続していた最大の日数を出力せよ。')
if S == 'SSS':
	print(0)
else if S == 'SSR':
	print(1)
else if S == 'SRR':
	print(2)
else if S == 'SRS':
	print(1)
else if S == 'RSS':
	print(1)
else if S == 'RRS':
	print(2)
else if S == 'RRR':
	print(3)
else if S == 'RSR':
	print(1)

### FIXED CODE ###

S = input()
if S == 'SSS':
  print(0)
elif S == 'SRR':
  print(2)
elif S == 'RRS':
  print(2)
elif S == 'RRR':
  print(3)
else:
  print(1)
r g b = map(int, input().split())
x = r*100+g*10+b
if x%4==0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

r,g,b= map(int, input().split())
x = r*100+g*10+b
if x%4==0:
  print("YES")
else:
  print("NO")
N, K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
S = []
R = -1000000001
#それぞれについての累積和の計算
for i in range(N):#このループはN個の初期マスの時のループ
    t = i  # tは現在の位置
    cnt = 0  # 累積和
    sum = []  # 累積和のリスト
    res = 0
    while True:#このループは一つの初期マスの累積和。最初のコマに戻るまで
        cnt += C[P[t]-1]
        t = P[t]-1
        sum.append(cnt)
        if t == i:
            break
    #S.append(sum)
    if len(sum) >=  K:
        res = max(sum[:K])
    else:
        if sum[-1] <= 0:
            res = max(sum)
        else:
            score1 = sum[-1] * (K // len(sum) - 1) + max(sum)
            score2 = sum[-1] * (K // len(sum)) + max(sum[0:K % len(sum)])
            res = max(score1,score2)
    R = max(R,res)
print(R)


### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for s in range(N):
    ### Step1
    S = []  # 累積和S. ただし, 初項は0ではなく1回目の移動後の得点とする.
    # 1回目の移動
    i = P[s] - 1
    S.append(C[i])
    # 2回目以降の移動. スタート地点に戻ってくるまで繰り返し.
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])

    ### Step2: KとSの長に応じて場合分けして, 得点の最大値を求める.
    # 1周未満しか移動できない場合:
    if K <= len(S):
        score = max(S[:K])
    # 1周以上回ることができるが, ループを1周したときに得点が減る場合:
    elif S[-1] <= 0:
        score = max(S)
    # 1週以上回ることができ, かつループを1週するごとに得点が増える場合:
    else:
        # ループを (K // len(S) - 1)回 廻る場合:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        # ループを (K // len(S))回 廻る場合:
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        # score1 と score2 の大きい方がこの場合の得点の最大値
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)
a,b,c = map(str, input().split())
d,e,f = map(str, input().split())
g,h,q = map(str, input().split())

print(a+e+q)

### FIXED CODE ###

a = input()
b = input()
c = input()

print(a[0]+b[1]+c[2])
a=list(input())
print(a.index(1))

### FIXED CODE ###

a=input()
print(a.count('1'))
x,y,z = map(int,input().split())
if x = y = z:
  print('Yes')
else:
  print('No)

### FIXED CODE ###

a,b,c = map(int,input().split())
if a+b>c and a+c>b and b+c>a:
  if a==b==c:
    print('Yes')
  else:
    print('No')
S = input()
W = input()

def sheep_wold(S=S, W=W):
    if S <= W:
        print('unsafe')
    else:
        print('safe')

### FIXED CODE ###

s, w =  map(int, input().split())
if s <= w:
    print('unsafe')
else:
    print('safe')
from bisect import bisect_left, bisect_right

N, K, Q = map(int, input().split())
A = [int(i) for i in input().split()]

ret = float('inf')
for i in range(N) :
    l = 0
    for j in range(i, max(-1, i - Q), -1) :
        if A[j] < A[i] :
            l = j + 1
            break
    r = N - 1        
    for j in range(i, min(N, i + Q + 1)) :
        if A[j] < A[i] :
            r = j - 1
            break
            
    if r - l + 1 < Q :
        continue
        
    B = A[::]
    B.pop(i)

    C = [-1]
    for j in range(N - 1) :
        if B[j] < A[i] :
            C.append(j)
    C.append(N - 1)

    D = []    
    for j in range(len(C) - 1) :
        if C[j+1] - C[j] - 1 >= K :
            D += sorted(B[C[j]+1:C[j+1]])[:C[j+1] - C[j] - K]
    
    if len(D) >= Q - 1 :
        D.sort()
        ret = min(ret, D[Q-2] - A[i])
        
print(ret)

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = [int(i) for i in input().split()]

def solve() :
    if Q == 1 : return 0
        
    ret = float('inf')
    for i in range(N) :
        l = -1
        for j in range(i, max(-1, i - K), -1) :
            if A[j] < A[i] :
                l = j
                break
        r = N      
        for j in range(i, min(N, i + K)) :
            if A[j] < A[i] :
                r = j
                break
                
        if r - l - 1 < K :
            continue
            
        B = A[::]
        B.pop(i)
        
        C = [-1]
        for j in range(N - 1) :
            if B[j] < A[i] :
                C.append(j)
        C.append(N - 1)
        
        D = []
        for j in range(len(C) - 1) :
            if C[j+1] - C[j] >= K :
                D += sorted(B[C[j]+1:C[j+1]])[:C[j+1] - C[j] - K]
        
        if len(D) >= Q - 1 :
            D.sort()
            ret = min(ret, D[Q-2] - A[i])

    return ret
    
print(solve())
n = int(input())
a = [ int(i) for i in input().split(" ")]

INF = 10000000000
dp = [ INF for i in range(len(a))]
dp[0] = 0

def frog(i):
  if dp[i] < INF: return dp[i]
  
  if i == 0: return 0

  res = INF
  res = min(res, frog(i-1) + abs(a[i-1] - a[i]))
  print("calc i-1", i)
  min(res, frog(i-1) + abs(a[i-2] - a[i]))
  print("calc i-2", i)

  dp[i] = res
  return res

print(frog(n-1))

### FIXED CODE ###

n = int(input())
a = [ int(i) for i in input().split(" ")]

dp = [ -1 for i in range(len(a))]
dp[0] = 0

for i in range(1, len(a)):
  onestep = dp[i-1] + abs(a[i-1] - a[i])
  if i - 2 < 0:
    twostep = onestep
  else:
    twostep = dp[i-2] + abs(a[i-2] - a[i])
  
  dp[i] = min(onestep, twostep)

print(dp[-1])
X,N=map(int, input().split())
p=list(map(int,input().split()))
p.sort()    
if N==0:
    print(X)
else:
    for k in range(0,51):
        if not X-k in p:
            print(X-k)
            break 
        elif not X+k in p_list:
            print(X+k)
            break

### FIXED CODE ###

X, N = map(int, input().split())
p_list = list(map(int, input().split()))

if N == 0: 
   print(X)
else:
   for i in range(0,100):
       if not X-i in p_list:
           print(X-i)
           break
       elif not X+i in p_list:
           print(X+i)
           break
N=int(input())
array=map(int,input().split())
A=[]
for i in array:
    A.append(i)

dict_num={i:0 for i in range(100000)}

Q=int(input())
matrix=[]
for i in range(Q):
    matrix.append(list(map(int,input().split())))

#全数値の合計計算
sum=0
#各数字の出現回数の計測
for i in range(len(A)):
    dict_num[A[i]]+=1
    sum+=A[i]

#合計の再計算 & 数字の出現回数の再計算
for i in matrix:
    sum+=(i[1]-i[0])*dict_num[i[0]]
    dict_num[i[1]]+=dict_num[i[0]]
    dict_num[i[0]]=0
    print(sum)

### FIXED CODE ###

N=int(input())
array=map(int,input().split())
A=[]
for i in array:
    A.append(i)

dict_num={i:0 for i in range(100050)}
Q=int(input())
matrix=[]
for i in range(Q):
    matrix.append(list(map(int,input().split())))

#全数値の合計計算
sum=0
#各数字の出現回数の計測
for i in range(N):
    dict_num[A[i]]+=1
    sum+=A[i]

#合計の再計算 & 数字の出現回数の再計算
for i in matrix:
    sum+=(i[1]-i[0])*dict_num[i[0]]
    dict_num[i[1]]+=dict_num[i[0]]
    dict_num[i[0]]=0
    print(sum)
from bisect import bisect_left, bisect_right
N = int(input())
S = input()
Q = int(input())

D = {chr(ord('a') + i): [] for i in range(26)}

for i, s in enumerate(S):
    D[s].append(i)

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1]), query[2]
        i -= 1
        s = S[i]
        if s == x:
            continue

        D[s].remove(i)
        next_i = bisect_left(D[x], i)
        D[x].insert(next_i, i)

    if query[0] == '2':
        l, r = int(query[1]), int(query[2])
        l, r = l - 1, r - 1
        ans = 0
        for i in range(26):
            s = chr(ord('a') + i)

            li = bisect_left(D[s], l)
            ri = bisect_right(D[s], r)

            if ri - li > 0:
                ans += 1

        print(ans)


### FIXED CODE ###

from bisect import bisect_left, bisect_right
N = int(input())
S = list(input())
Q = int(input())

D = {chr(ord('a') + i): [] for i in range(26)}

for i, s in enumerate(S):
    D[s].append(i)

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1]), query[2]
        i -= 1
        s = S[i]
        if s == x:
            continue

        D[s].remove(i)
        next_i = bisect_left(D[x], i)
        D[x].insert(next_i, i)
        S[i] = x

    if query[0] == '2':
        l, r = int(query[1]), int(query[2])
        l, r = l - 1, r - 1
        ans = 0
        for i in range(26):
            s = chr(ord('a') + i)

            li = bisect_left(D[s], l)
            ri = bisect_right(D[s], r)

            if ri - li > 0:
                ans += 1

        print(ans)
n = int(input())
s = input()

lst = []
for i in range(1,n-1):
    left = s[:i]
    right = s[i:]

    cnt = 0
    for j in set(left):
        if j in set(right):
            cnt += 1
    lst.append(cnt)
    
print(max(lst))

### FIXED CODE ###

n = int(input())
s = input()

lst = []
for i in range(1,n-1):
    left = s[:i]
    right = s[i:]

    cnt = 0
    for j in set(left):
        if j in set(right):
            cnt += 1
    lst.append(cnt)

if not lst:
    print(0)
else:
    print(max(lst))
import sys
import bisect
from collections import deque

fastinput = sys.stdin.readline
N = int(fastinput())
A = [int(fastinput()) for j in range(N)]
surface = deque([A[0]])#常に小さい順にソートされている
surfMax = A[0]
surfMin = A[0]
color = 1
for n,a in enumerate(A):
    if n==0:
        continue
    if a<=surfMin:
        color += 1
        surface.appendleft(a)
        surfMin = a
    elif a>surfMax:
        surface[color-1] = a
        surfMax = a
    else:
        pos = bisect.bisect_left(surface,a) -1 #a未満の最大の整数
        surface[pos-1] = a
        if pos==0:
            surfMin = a
print(color)


### FIXED CODE ###

import sys
import bisect
from collections import deque

fastinput = sys.stdin.readline
N = int(fastinput())
A = [int(fastinput()) for j in range(N)]
surface = deque([A[0]])#常に小さい順にソートされている
surfMax = A[0]
surfMin = A[0]
color = 1
for n,a in enumerate(A):
    if n==0:continue

    if color == 1:
        c = surface[0]
        if a>c:
            surface[0] = a
            surfMax = a
            surfMin = a
        if a==c:
            surface.appendleft(a)
            color += 1
        if a<c:
            surface.appendleft(a)
            color += 1
            surfMin = a

    else:    
        if a<=surfMin:
            color += 1
            surface.appendleft(a)
            surfMin = a
        elif a>surfMax:
            surface[color-1] = a
            surfMax = a
        else:
            pos = bisect.bisect_left(surface,a) -1 #a未満の最大の整数
            surface[pos] = a
            if pos==0:
                surfMin = a
            if pos == color-1:
                surfMax = a
print(color)
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
ilist = [ tuple(zip(tuple(map(int, input().split())), ("a","b","c"))) for i in range(N)]

# print(ilist)
suml = [(0,"z")]
for i in range(1,N+1):
    l = (ilist[i-1])
    l = sorted(l, reverse=True)
    # print("list: ", l)
    if suml[i-1][1] != l[0][1]:
        # suml[i] = suml[i-1] + l[0][0]
        if (i+1)<=N and sorted(ilist[i+1], reverse=True)[0][1] == l[0][1]:
            # print("\tinside")
            l_n = sorted(ilist[i+1], reverse=True)# [0][1]
            if (l[0][0] + l_n[1][0]) < (l[1][0] + l_n[0][0]):

                suml.append(( suml[i-1][0]+l[1][0], l[1][1]  ))
            else:
                suml.append(( suml[i-1][0]+l[0][0], l[0][1]  ))
        else:
            suml.append(( suml[i-1][0]+l[0][0], l[0][1]  ))

        # // l[0][1] == sorted(ilist[i+1], reverse=True)[0][1]  \
        #  and l[0][0] + sorted(ilist[i+1], reverse=True)[0][1]
    else:
        # suml[i] = suml[i-1] + l[1][0]
        suml.append(( suml[i-1][0]+l[1][0], l[1][1]  ))

# print(suml)
print(suml[-1][0])





### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
# info = [ tuple(zip(tuple(map(int, input().split())), ("a","b","c"))) for i in range(N)]
info = [list(map(int, input().split())) for i in range(N)]
dp = [[0,0,0] for i in range(N+1)]
dp[1] = info[0]
for i in range(N):
    for j in range(3):
        for k in [x for x in range(3) if x != j]:
            if dp[i][k] + info[i][j] > dp[i+1][j]: # dp[i+1][j]?
                dp[i+1][j] = dp[i][k] + info[i][j]

# print(dp)
print(max(dp[N]))
n, k = map(int, input().split())
s = input()
print(s[:k]+s[k].lower()+s[k+1:])


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
print(s[:k-1]+s[k-1].lower()+s[k:])
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
m = 1000000

count = 0
cnt = [0] * m
for i in range(n):
  if cnt[a[i]] == 0:
    for j in range(a[i], m, a[i]):
      cnt[j] += 1
  else:
    cnt[a[i]] = 2
for i in range(n):
  if cnt[a[i]] == 1:
    count += 1
print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
m = 1000005

count = 0
cnt = [0] * m
for i in range(n):
  if cnt[a[i]] == 0:
    for j in range(a[i], m, a[i]):
      cnt[j] += 1
  else:
    cnt[a[i]] = 2
for i in range(n):
  if cnt[a[i]] == 1:
    count += 1
print(count)
n=int(input())
a=set()
for i in range(n):
    b=int(input())
    if b in a:
        a.remove(b)
    else:
        a.append(b)
print(len(a))

### FIXED CODE ###

import sys
input=sys.stdin.readline
n=int(input())
a=[int(input()) for _ in range(n)]
a.sort()
h=a[0]
ans=1
for i in a[1:]:
    if i!=h:
        ans+=1
        h=i
    else:
        ans-=1
        h=pow(10,10)    
print(ans)
W,a,b=map(int,input().split(' '))
print(max(0,b-(a+W)) if a<=b else print(max(0,a-(b+W)))

### FIXED CODE ###

W,a,b=map(int,input().split(' '))
print(max(0,b-(a+W))) if a<=b else print(max(0,a-(b+W)))
n=input().split(' ')
a=int(n[0]);b=int(n[1])
import sympy
print(sympy.lcm(a,b))

### FIXED CODE ###

n=input().split(' ')
a=int(n[0]);b=int(n[1])
def gcd(a,b):
    x=max(a,b);y=min(a,b)
    if x%y==0:
        return y
    while x%y!=0:
        z=x%y ; x=y ; y=z
    return z
print(int(a*b/gcd(a,b)))
n.k = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
import itertools
import math
cnt_nPk = math.factorial(n)/math.factorial(k)
P_nPk = list(itertools.permutations(n,k))

for i in range(n):
  a = sum(P_nPk[i])
  ans += a

print(ans / cnt_nPk)


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    tmp_max = sum(P[:K])
    tmp = sum(P[:K])
    for i in range(N-K):
        tmp += P[i+K]
        tmp -= P[i]

        if tmp > tmp_max:
            tmp_max = tmp

    print((tmp_max + K) / 2)

main()
N = str(input())

ans = 0
for i in range(1, N+1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i
print(ans)

### FIXED CODE ###

N = int(input())
 
ans = 0
for i in range(1, N+1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i
print(ans)
# 2019/07/16
# AtCoder Grand Contest 021 - A
# For the answer: 
# 1. 桁分割、桁数Count
# 2-1. 上位桁から9以外を探索
# 2-2. 9以外があれば、その1つ上桁を-1
# 2-3. ただし先頭の場合は自身を-1
# 3. (桁数-1)*9 + 上位桁-1

# Input
n = int(input())

# 1.
wn = n
ketalist = list()
while wn > 0:
    ketalist.append(wn % 10)
    wn = int(wn / 10)

# 2. 
ketalist.reverse()
for i in range(len(ketalist)):
    if ketalist[i] < 9:
        if i == 0:
            tgtnum = ketalist[i] - 1
        else:
            tgtnum = ketalist[i-1] - 1
        break

# 3.
if len(ketalist) > 1:
    if ketalist[0] == 1:
        ans = (len(ketalist) - 1) * 9
    else:
        ans = (len(ketalist) - 1) * 9 + tgtnum
else:
    ans = n

# Output
print(ans)


### FIXED CODE ###

# 2019/07/17
# AtCoder Grand Contest 021 - A
# For the answer: 
# 1. 桁分割、桁数Count
# 2-1. 上位桁から9以外を探索
# 2-2. 9以外があれば、その1つ上桁を-1
# 2-3. ただし先頭の場合は自身を-1
# 3. (桁数-1)*9 + 上位桁-1

# Input
n = int(input())

# 1.
wn = n
ketalist = list()
defans = 0
while wn > 0:
    remn = wn % 10
    defans = defans + remn
    ketalist.append(remn)
    wn = int(wn / 10)

# 2. 
ketalist.reverse()
allflg = False
for i in range(len(ketalist)):
    if ketalist[i] < 9:
        if i == 0:
            tgtnum = ketalist[i] - 1
        else:
            tgtnum = ketalist[i-1] - 1
        break
    # Case all 9:
    if i == len(ketalist) - 1:
        allflg = True

# 3.
if len(ketalist) > 1 and allflg == False:
    if ketalist[0] == 1:
        ans = (len(ketalist) - 1) * 9
    else:
        ans = (len(ketalist) - 1) * 9 + tgtnum
elif len(ketalist) > 1 and allflg == True:
    ans = len(ketalist) * 9
else:
    ans = n

# Output
print(max(ans, defans))
n=int(intput())
s=set(input() for _ in range(n))
print(len(s))

### FIXED CODE ###

n=int(input())
a = [input() for i in range(n)]
print(len(set(a)))
import math
from functools import reduce


N = int(input())
A = [int(i) for i in input().split()]
print(reduce(math.gcd, A))


### FIXED CODE ###

from fractions import gcd
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
print(reduce(gcd, A))
# 052

# 1.値を正しく取得
x1 = int(input())
y1 = int(input())
x2 = int(input())
y2 = int(input())

# 2.正しく処理

menseki1 = x1 * y1
print(menseki1)
menseki2 = x2 * y2
print(menseki2)

if menseki1 > menseki2:
    print(menseki1)

elif menseki1 < menseki2:
    print(menseki2)

else :
    print(menseki1)

### FIXED CODE ###

# 052

# 1.値を正しく取得
a,b,c,d=(int(x) for x in input().split())

# 2.正しく処理

menseki1 = a * b
menseki2 = c * d

if menseki1 > menseki2:
    print(menseki1)

elif menseki1 < menseki2:
    print(menseki2)

else :
    print(menseki1)
a,b = list(map(int, input().split()))
s = [input() for i in range(a)]
num = []
for i in range(a):
    ss = s[i]
    numm = []
    for j in range(b):
        if  ss[j]== ".":
            numm.append(0)
        else:
            numm.append("#")
    num.append(numm)
#四隅の判定
if num[0][0] == 0:
    if num[0][1] == "#":
        num[0][0] += 1
    if num[1][0] == "#":
        num[0][0] += 1
    if num[1][1] == "#":
        num[0][0] += 1

if num[0][-1] == 0:
    if num[0][-2] == "#":
        num[0][-1] += 1
    if num[1][-1] == "#":
        num[0][-1] += 1
    if num[1][-2] == "#":
        num[0][-1] += 1

if num[-1][0] == 0:
    if num[-1][1] == "#":
        num[-1][0] += 1
    if num[-2][0] == "#":
        num[-1][0] += 1
    if num[-2][1] == "#":
        num[-1][0] += 1

if num[-1][-1] == 0:
    if num[-1][-2] == "#":
        num[-1][-1] += 1
    if num[-2][-1] == "#":
        num[-1][-1] += 1
    if num[-2][-2] == "#":
        num[-1][-1] += 1

for i in range(1,a-1):
    for j in range(1,b-1):
        if num[i][j] == 0:
            num[i][j] += num[i-1][j-1:j+2].count("#")
            num[i][j] += str(num[i][j-1]).count("#")
            num[i][j] += str(num[i][j+1]).count("#")
            num[i][j] += num[i+1][j-1:j+2].count("#")

for i in range(1,b-1):
    if num[0][i] == 0:
        num[0][i] += str(num[0][i-1]).count("#")
        num[0][i] += str(num[0][i+1]).count("#")
        num[0][i] += num[1][i-1:i+2].count("#")
    if num[-1][i] == 0:
        num[-1][i] += num[-2][i-1:i+2].count("#")
        num[-1][i] += str(num[-1][i-1]).count("#")
        num[-1][i] += str(num[-1][i+1]).count("#")

for i in range(1,a-1):
    if num[i][0] == 0:
        num[i][0] += str(num[i-1][0:2]).count("#")
        num[i][0] += str(num[i][1]).count("#")
        num[i][0] += num[i+1][0:2].count("#")
    if num[i][-1] == 0:
        num[i][-1] += num[i-1][-2:].count("#")
        num[i][-1] += str(num[i][-2]).count("#")
        num[i][-1] += str(num[i+1][-2:]).count("#")

for i in num:
    print("".join(list(map(str,i))))

### FIXED CODE ###

H,W = map(int,input().split())
src = [input() for i in range(H)]
 
ans = []
for row in src:
    ans.append(list(row))
 
dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]
for y in range(H):
    for x in range(W):
        if src[y][x] == '#': continue
        c = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
            if src[y+dy][x+dx] == '#': c += 1
        ans[y][x] = c
 
for row in ans:
    print(''.join(list(map(str,row))))
import sys

x = sys.stdin
print x**3

### FIXED CODE ###

import sys

x = sys.stdin.read()

print int(x)**3