Harryxun/stf_run huggingface dataset:
length = raw_input()
count = length
answer = raw_input()

def compare(current, i):
  if current[i] < answer[i]:
    answer = current
  elif current[i] == answer[i]:
    compare(current, i+1)

while count > 0:
  if count < length:
    current_word = raw_input()
    compare(current_word, 0)
  count -= 1

print answer
  

### FIXED CODE ###

s = []
n = input()
 
for i in range(n):
    x = raw_input()
    s.append(x)
 
s.sort()
 
print s[0]
N, M = [int(i) for i in input().split(' ')]
SC = []
for _ in range(M):
    SC.append([int(i) for i in input().split(' ')])

for n in range(10**(N-1),10**N):
    n = list(str(n))
    flg = 0
    for s,c in SC:
        if not n[s-1] == str(c):
            flg = 1

    if flg == 0:
        print(''.formatjoin(n))
        exit()

### FIXED CODE ###

N, M = [int(i) for i in input().split(' ')]
SC = []
for _ in range(M):
    SC.append([int(i) for i in input().split(' ')])

ch = [-1] * N
for s,c in SC:
    if N >1:
        if s == 1 and c == 0:
            print(-1)
            exit()

    if ch[s-1] == -1 or ch[s-1] == c:
        ch[s-1] = c
    else:
        print(-1)
        exit()
s = 10**(N-1) if N >1 else 0
f = 10 ** N if N >1 else 10
for n in range(s,f):
    n = list(str(n))
    flg = 0
    for s,c in SC:
        if not n[s-1] == str(c):
            flg = 1

    if flg == 0:
        print(''.join(n))
        exit()
N = int(input())
A = list(map(int,input().split(",")))
tmp = 0
for i in range(N):
  tmp = tmp + 1/A[i]
  
print(1/tmp)

### FIXED CODE ###

N = int(input())
A = list(map(float,input().split()))
tmp = 0
for i in range(N):
  tmp = tmp + (1/A[i])
tmp= 1/tmp
print(tmp)
N=input
s=[int(input()) for i in range(N)]
print(len(list(set(s))))

### FIXED CODE ###

N=int(input())
s=[int(input()) for i in range(N)]
print(len(set(s)))
n = int(input())
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
if l%2==1:
    mid = b[l//2+1]
else:
    mid = (b[l//2] + b[l//2+1]) // 2
sum = 0
for i in range(n):
    sum += abs(a[i] - mid - (i+1))
print(sum)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
mid = b[l//2]
sum = 0
for i in range(n):
    sum+=abs(a[i]-(mid+(i+1)))
print(sum)
N=int(input())
D=int(input())
ans = 0
i=1
while i<=N:
  i+=1
  X=int(input())
  Y=int(input())
  if X * X + Y * Y <= D * D:
    ans += 1
print(ans)


### FIXED CODE ###

N, D = map(int,input().split())
ans = 0
i = 1
while i <= N:
  i += 1
  X, Y = map(int,input().split())
  
  if X * X + Y * Y <= D * D:
    ans += 1
print(ans)
n=int(input())
s=[map(str,input().split())]
print("Four" if "Y" in s: else: "Three")

### FIXED CODE ###

input()
print("Four" if "Y" in input() else "Three")
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
 
 
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
    def find(self, i):
        parent = self.parents[i]
        if parent == i:
            return i
        else:
            self.parents[i] = self.find(self.parents[i])
            return self.parent[i]
    def unite(self, i, j):
        pi = self.find(i)
        pj = self.find(j)
        self.sizes[pj] += self.sizes[pi]
        self.parents[pi] = pj 
        
 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.sizes[px] * uf.sizes[py]
            uf.unite(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()


### FIXED CODE ###

N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
 
 
class UnionFind:
    def __init__(self,size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]
 
    def find(self,x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x
 
    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]
 
 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.number[px] * uf.number[py]
            uf.union(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()
H,A=map(int,input())
print(H//A+1)

### FIXED CODE ###

H,A=map(int,input().split())
print((H+A-1)//A)
A,B = map(int,input(),split())

if A <10 and B < 10:
	print(A*B)
else:
	print('-1')
	
	

### FIXED CODE ###

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

if A <10 and B < 10:
	print(A*B)
else:
	print('-1')
N,T=input().split()
min=1001
for i in range(N):
  cost,time=input().split()
  if time<=T and cost<min:
    min=cost
if min==1001:
  print('TLE')
else:
  print(min)

### FIXED CODE ###

N,T=input().split()
min=1001
for i in range(int(N)):
  cost,time=input().split()
  if int(time)<=int(T) and int(cost)<min:
    min=int(cost)
if min==1001:
  print('TLE')
else:
  print(min)
s = input()

s=s.sorted()
if s[0]!=s[1] or s[2]!=s[3] or s[0]==s[3]:
	Print("No")
elif :
	print("Yes")

### FIXED CODE ###

s = sorted(input())


if s[0]!=s[1] or s[2]!=s[3] or s[0]==s[3]:
	print("No")
else :
	print("Yes")
import numpy as np

N,M=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
A.sort()

A = np.array(A)

cnt = 0
for day in range(1,M+1):
    B = A[A[:,0]<=day,1]
    if B.size > 0:
        index = np.argmax(B)
        cnt += B[index]
        A = np.delete(A,index,0)

print(cnt)

### FIXED CODE ###

from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
q=[0]*10**5
v=[[]for _ in q]
z=0
for a,b in t:v[a-1]+=[b]
for i in v[:M]:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)
a,b=map(int,input())
l=[a+b,a-b,a*b]
print(max(l))

### FIXED CODE ###

a,b=map(int,input().split())
l=[a+b,a-b,a*b]
print(max(l))
N, A, B, K = map(int, input().split())
mod = 998244353

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r or n == 0 or r == 0:
        return 0
    return factorial[n] * inverse[r] * inverse[n - r] % mod


ans = 0
for r in range(N+1):
    b = (K - A*r) / B
    # 青で塗る箇所が整数ならば
    if b == (K-A*r) // B:
        ans += nCr(N, r) * nCr(N, int(b)) % mod

print(ans)


### FIXED CODE ###

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

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


ans = 0
for r in range(N+1):
    b = (K - A*r) / B
    # 青で塗る箇所が整数ならば
    if b == (K-A*r) // B and 0 <= b <= N:
        ans += nCr(N, r) * nCr(N, int(b)) % mod

print(ans % mod)
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
b = len(A) - len(list(set(A)))
c = 0
AA = []
for i in range(1,N):
    for j in range(i):
        if A[i] == A[i-1]:
            break
        elif A[i] % A[j] == 0:
            c += 1
            break
        elif j == i-1:
            AA.append(A[i])
if A[0] == A[1]:
    print(len(AA))
else:
    print(len(AA)+1)

### FIXED CODE ###

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

s = A[-1]
p = [0 for _ in range(s+1)]
for i in A:
    p[i] += 1
    if p[i] > 1:
        continue
    for j in range(i*2,s+1,i):
        p[j] += 1
ans = 0
for i in A:
    if p[i] == 1:
        ans += 1
print(ans)
K = int(input())


if K%2 == 0:
	print(K//2)*(K//2)
else:
	print(K*K-1)//4


### FIXED CODE ###

k = int(input())

if k % 2 == 0:
    print((k//2)**2)
else:
    print((k//2)*((k//2)+1))
from math import floor
a, b = map(int, input().split())
ans = -1
for i in range(10101):
  if floor(i*0.08) = a and floor(i*0.1) = b:
    ans = i
    break
print(ans)

### FIXED CODE ###

from math import floor
a, b = map(int, input().split())
ans = -1
for i in range(10101):
  if floor(i*0.08) == a and floor(i*0.1) == b:
    ans = i
    break
print(ans)
H, N = map(int, input().split())
damage = []
mp = []

for i in range(N):
    a, b = map(int, input().split())
    damage.append(a)
    mp.append(b)

dp = [[0]+[float("inf")]*H for _ in range(N + 1)]

for j in range(1, H + 1):
    if j % damage[0] == 0:
        x = j // damage[0]
    else:
        x = j // damage[0] + 1 
    dp[1][j] = x * mp[0]

for i in range(1, N):
    for j in range(H + 1):
        dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - damage[i]] + mp[i])

for i, row in enumerate(dp):
    if i == 0:
        continue
    buf = float("inf")
    for j in range(H + 1):
        if row[H - j] > buf:
            row[H - j] = buf
        buf = row[H - j]

print(dp[N][H])

### FIXED CODE ###

H, N = map(int, input().split())
damage = []
mp = []
 
for i in range(N):
    a, b = map(int, input().split())
    damage.append(a)
    mp.append(b)
 
dp = [[0]+[float("inf")]*H for _ in range(N + 1)]

for i in range(N):
    for j in range(H + 1):
        if j - damage[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - damage[i]] + mp[i])
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][0] + mp[i])

print(dp[N][H])
from math import gcd
N=int(input())
A=list(map(int,input().split()))
left,right=[0],[0]
[(left.append(gcd(left[i],A[i])),right.append(gcd(right[i],A[N-i-1]))) for i in range(N-1)]
right.reverse()
print(max([gcd(a,b) for a,b in zip(left,right)]))

### FIXED CODE ###

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

def gcd(x,y):
    if y > x:
        x,y = y,x
    if y == 0:
        return x
    if x%y == 0:
        return y
    else:
        return gcd(x%y,y)

L = [0]
for i in range(N):
    L.append(gcd(L[i],A[i]))
R = [0]
for i in range(N):
    R.append(gcd(R[i],A[-(i+1)]))

print(max([gcd(L[i],R[N-i-1]) for i in range(N)]))
r,g,b = int(input()).split()

if int("r+g+b")%4 == 0:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

r,g,b = map(int,input().split())

a = r * 100 + g * 10 + b
if a % 4 == 0:
  print("YES")
else:
  print("NO")
a = [int(input()) for i in range(4)]
count = 0
y = a[3]
i = y / 500; if i > a[0] : i = a[0]; y -= i * 500
j = y / 100; if j > a[1] : j = a[1]; y -= j * 100
k = y /  50; if k > a[2] : k = a[2]; y -= k * 50
if (y == 0) :
  count += 1
  if i > 0 :
    while (i > 0 and j + 5 <= a[1]) :
      i -= 1
      j += 5
      tmp1 = j
      tmp2 = k
      count += 1
      while (tmp1 > 0 and tmp2 + 2 <= a[2]) :
        tmp1 -= 1
        tmp2 += 2
        count += 1
      tmp1 = j
      tmp2 = k
  elif i == 0 and j > 0:
    while (j > 0 and k + 2 <= a[2]) :
        j -= 1
        k += 2
        count += 1

print(count)


### FIXED CODE ###

a = [int(input()) for i in range(4)]
count = 0

for i in range(a[0]+1) :
  for j in range(a[1]+1) :
    for k in range(a[2]+1) :
      sum = 500*i + 100*j + 50*k
      if sum == a[3] :
        count += 1
print(count)
num_a = int(A)
num_b = int(B)
dif = num_a - num_b*2
if dif >= 0:
  print(dif)
else:
  print(0)

### FIXED CODE ###

a, b = input().split()
num_a = int(a)
num_b = int(b)
dif = num_a - num_b*2
if dif >= 0:
  print(dif)
else:
  print(0)
S = input()

if S[0] == 'A' and (S[:3] + S[-2:]).count('C') == 1:
    a = 0
    c = 0
    ng = 0
    for ch in S:
        if ch == 'A':
            a += 1
        elif ch == 'C':
            c += 1
        elif not ch.islower():
            ng += 1
    if a == 1 and c == 1 and ng == 0:
        print("AC")
        sys.exit(0)
print("WA")


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

S = input()

if S[0] == 'A' and S[2:-1].count('C') == 1:
    S2 = S.replace('A', '').replace('C', '')
    if len(S2) == len(S) - 2 and S2.islower():
        print("AC")
        sys.exit(0)
print("WA")
N = int(input()
H = list(map(int, input().split()))
ans = 0
for i in range(N):
  for j in range(i):
    if H[i]>=H[j]:
  ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
ans = 1
for i in range(1,N):
  if H[i]>=max(H[:i]):
    ans += 1
print(ans)
N,M = map(int,input().split())
li = []
numb = []
ans = ''
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        li.append(b)
    elif b == N:
        numb.append(a)
for i in range(M):
  if li[i] in numb:
    ans = 'POSSIBLE'
    break
if ans == '':
  print('IMPOSSIBLE')
else:
  print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
li = []
numb = []
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        li.append(b)
    elif b == N:
        numb.append(a)
ans = set(li) & set(numb)
if len(ans) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
n = list(map( int, split()))
 
h = 3
for i in range(h):
  if( n[i] == 1):
    n[i] = 9
    n[i] = str(n[i])   
  else:
    n[i] = 1
    n[i] = str(n[i])
    
a = "".join(n)
 
print(a)

### FIXED CODE ###

n = list(map( int, input()))
 
h = 3
for i in range(h):
  if( n[i] == 1):
    n[i] = 9
    n[i] = str(n[i])   
  else:
    n[i] = 1
    n[i] = str(n[i])
    
a = "".join(n)
 
print(a)
a=list(map(int,input().split()));print(min(a[:1])+min(a[2:]))

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
z=[a,b,c,d]
print(min(z[:2])+min(z[2:]))
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = inpl()

ss = sum(A)
s = 0
for i in range(len(A)):
    s = (s + sum(A[i+1:])*A[i]) % mod

print(s)

### FIXED CODE ###

import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = inpl()

sss = list(itertools.accumulate(A))
ss = sum(A)
s = 0
for i in range(len(A)-1):
    s = (s + ((ss-sss[i]) * A[i])) % mod

print(s)
n = input()
m = input()
lst = []
if m in n:
    print(0)
else:
    for i in range(len(n) - len(m)):
        count = 0
        for j in range(i, len(m) + i):
            if n[j] != m[j-i]:
                count += 1
        lst.append(count)
    print(min(lst))

### FIXED CODE ###

n = input()
m = input()
lst = []
if m in n:
    print(0)
else:
    for i in range(len(n) - len(m) + 1):
        count = 0
        for j in range(i, len(m) + i):
            if n[j] != m[j-i]:
                count += 1
        lst.append(count)
    print(min(lst))
a,b=map(int,input().split())

print(max([a*b,a-b,a+B]))


### FIXED CODE ###

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

print(max(a*b,a-b,a+b))
x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)
    if d[key]>=4:
        g.append(key)
b.sort()
g.sort()
if len(b)<2 and len(g) == 0:
    print 0
else:
    print max(b[len(b)-1]*b[len(b)-2], g[len(g)-1]*g[len(g)-1]

### FIXED CODE ###

x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)
    if d[key]>=4:
        g.append(key)
b.sort()
g.sort()
if len(b)<2 and len(g) == 0:
    print 0
else:
    if len(b)<2:
        b.append(0)
        b.append(0)
    if len(g)==0:
        g.append(0)
    print max(b[len(b)-1]*b[len(b)-2], g[len(g)-1]*g[len(g)-1])
if __name__ == "__main__":
	N = int(input())
	L = list(map(int, input().split()))
	L.sort()
	sum = 0
	for c in range(2, N):
		for b in range(c - 1, 0, -1):
			for a in range(b - 1, -1, -1):
				if L[a] + L[b] > L[c]:
					# print(a, b, c)
					sum += 1
				else:
					break
	print(sum)

### FIXED CODE ###

if __name__ == "__main__":
	A, B = map(int, input().split())
	ans = A - 2 * B
	if ans < 0:
		ans = 0
	print(ans)
import numpy as np
n,m = map(int,input().split())
a=np.zeros(m,dtype=int64)
for i in range(n):
    li = list(map(int,input().split()))
    for j in range(li[0]):
        a[li[j+1]-1]=a[li[j+1]-1]+1
ans=0
for i in range(m):
    if a[i]==n:
        ans=ans+1
print(ans)

### FIXED CODE ###

import numpy as np
n,m = map(int,input().split())
a=np.zeros(m,dtype=np.int64)
for i in range(n):
    li=[]
    li = list(map(int,input().split()))
    
    for j in range(li[0]):
        a[li[j+1]-1]=a[li[j+1]-1]+1
        
ans=0
for i in range(m):
    if a[i]==n:
        ans=ans+1
print(ans)
def abc():
    a, b, c = map(int, input().split())
    n = list(range(a, b + 1))
    for s in sorted(set(n[:c]) | set(n[-c:])):
        print(s)


abc()


### FIXED CODE ###

def abc():
    a, b, c = map(int, input().split())
    n = range(a, b + 1)
    for s in sorted(set(n[:c]) | set(n[-c:])):
        print(s)


abc()
import functools
import math
N,X = map(int,input().split())
city = [int(c) for c in input().split()]
diff = []
for i in range(N):
    diff.append(city[i]-X)

gcd = functools.reduce(math.gcd,diff)
print(gcd)

### FIXED CODE ###

import functools
import fractions
N,X = map(int,input().split())
city = [int(c) for c in input().split()]
diff = []
for i in range(N):
    diff.append(city[i]-X)

gcd = functools.reduce(fractions.gcd,diff)
print(abs(gcd))
s = int(input())
lst = []
cnt = 0
While True:
  cnt += 1
  if (s % 2 == 0):
    s = int(s / 2)
  else:
    s = int(3*s + 1)
  lst.append(s)
  if (s in lst):
    break
print(cnt)
    
    

### FIXED CODE ###

s = int(input())
lst = []
lst.append(s)
cnt = 1
while (True):
  cnt += 1
  if (s % 2 == 0):
    s = int(s / 2)
  else:
    s = int(3*s + 1)
  if (s not in lst):
    lst.append(s)
  else:
    break
print(cnt)
N, M = map(int, input().split())
t_list = [[0] * 2 for _ in range(M)]
ans = 0
is_change = False
for i in range(M):
  t_list[i] = list(map(int, input().split()))
bottom = t_list[i][0]
up = t_list[i][1]
for i in range(M):
  t_bottom = t_list[i][0]
  t_up = t_list[i][1]
  if t_bottom > bottom and t_bottom <= up:
    bottom = t_bottom
    is_change = True
  if t_up < up and t_up >= bottom :
    up = t_up
    is_change = True
if is_change:
  print(ans)
else:
  print("0")

### FIXED CODE ###

A, B = map(int, input().split())
if A >= 13:
  print(B)
elif A <= 12 and A >= 6:
  print(B//2)
elif A <= 5:
  print("0")
import numpy as np

h, w = map(int, input().split())
b = [[0] * w for _ in range(h)]
iq = []

for i in range(h):
    for j, m in enumerate(input()):
        if m == "#":
            iq.append((i, j))
            b[i][j] = 1

def bfs(q, cnt):
    nq = []
    for y, x in q:
        if y > 0:
            if not b[y-1][x]:
                b[y-1][x] = 1
                nq.append((y-1, x))
        if y < h-1:
            if not b[y+1][x]:
                b[y+1][x] = 1
                nq.append((y+1, x))
        if x > 0:
            if not b[y][x-1]: 
                b[y][x-1] = 1
                nq.append((y, x-1))
        if x < w-1:
            if not b[y][x+1]: 
                b[y][x+1] = 1
                nq.append((y, x+1))
                
    if nq: return bfs(nq, cnt + 1)
    return cnt
    
print(bfs(iq, 0))


### FIXED CODE ###

h, w = map(int, input().split())
b = [[0] * w for _ in range(h)]
q = []

for i in range(h):
    for j, m in enumerate(input()):
        if m == "#":
            q.append((i, j))
            b[i][j] = 1

cnt = -1

while q:
    nq = []
    for y, x in q:
        if y > 0:
            if not b[y-1][x]:
                b[y-1][x] = 1
                nq.append((y-1, x))
        if y < h-1:
            if not b[y+1][x]:
                b[y+1][x] = 1
                nq.append((y+1, x))
        if x > 0:
            if not b[y][x-1]: 
                b[y][x-1] = 1
                nq.append((y, x-1))
        if x < w-1:
            if not b[y][x+1]: 
                b[y][x+1] = 1
                nq.append((y, x+1))
    
    q = nq    
    cnt += 1
    
print(cnt)
while True:
  inl=map(int, raw_input().split())

  if inl==[]:
    break
  num=inl[0]+inl[1]
  a=list(str(num))

  time=0
  for i in a:
    time+=1

  print time

### FIXED CODE ###

import sys

a = []
for line in sys.stdin:
    a.append(line)

for n in a:
    inl=n.split()
    num=int(inl[0])+int(inl[1])
    l=list(str(num))
    time=0
    for i in l:
        time+=1
    print time
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda a, b: b)

compressed = []
while demands:
    a, b = demands.pop()

    for i, (ai, bi) in enumerate(compressed):
        if b <= ai or bi <= a:
            continue

        else:
            compressed[i] = [max(a, ai), min(b, bi)]
            break

    else:
        compressed.append([a, b])

print(len(compressed))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
# demands = [tuple(map(int, input().split())) for i in range(m)]
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda x: x[1])

compressed = []
while demands:
    a, b = demands.pop()

    for i, (ai, bi) in enumerate(compressed):
        if b <= ai or bi <= a:
            continue

        else:
            compressed[i] = [max(a, ai), min(b, bi)]
            break

    else:
        compressed.append([a, b])

print(len(compressed))
H, W = map(int, input(),split())
h, w = map(int, input(),split())
print((H-h)*(W-w))


### FIXED CODE ###

H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))