Harryxun/stf_run huggingface dataset:
w, h, n = list(map(int,input().split()))

init_w, init_h, init_w2, init_h2 = 0,0,w,h
for i in range(n):
  x, y, a = list(map(int,input().split()))
  
  if a ==1:
    init_w = x
  elif a==2:
    init_w2 = x
  elif a==3:
    init_h = y
  elif a==4:
    init_h2 = y

area = (init_w2-init_w)*(init_h2-init_h)
if area<=0:
  area = 0
print(area)




### FIXED CODE ###

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

if c==b+a:
  print("Yes")
  
else:
  print("No")
from sys import stdin
import sys
sys.setrecursionlimit(10*10)

ans = []


def problem_a(input_string):
    S = int(input_string[0].rstrip())
    N = input_string[1].rstrip()
    #print(S, N)

    #% (10^9 + 7)
    #return count_0
    N_l = len(N)
    for i in range(N_l):
        b(N, N[i], i)
    #print(list(set(ans)))
    #print(10**9 + 7)

    # 2
    #return len(list(set(ans))) % (10**9 + 7)
    for i in range(N_l):
        ans.append(N[i])
    #print(ans)
    return len(ans) % (10**9 + 7)


def b(org_array, temp, i):
    if len(org_array)-1 == i:
        return
    else:
        #print("org array:"+org_array)
        #ans.append(temp)
        #print(temp)
        if org_array[i+1] not in temp:
            b(org_array, temp, i+1)
            temp += org_array[i+1]
            ans.append(temp)
        #print("org: "+org_array[i+1])
        #print(temp)
        b(org_array, temp, i+1)


def main():
    input_line = stdin.readlines()
    answer = problem_a(input_line)
    print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin
import math
import itertools


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# これだと、O(n*n)
"""
temp_ans = []


def problem_a(input_string):
    S = int(input_string[0].rstrip())
    N = input_string[1].rstrip()
    N_l = len(N)
    global temp_ans
    for i in range(N_l)[::-1]:
        temp_ans += N[i]
        #print(temp_ans)
        for s in temp_ans:
            #print(s)
            if N[i] not in s:
                temp_ans.append(N[i]+s)
    #print(temp_ans)
    return len(temp_ans) % (10**9 + 7)
"""


def problem_a(input_string):
    S = int(input_string[0].rstrip())
    N = input_string[1].rstrip()
    #print(S)
    dic = {}
    c = 0
    for i in range(S)[::-1]:
        if N[i] not in dic:
            dic[N[i]] = 1
            #c += i+1
        else:
            dic[N[i]] += 1

    c = 1
    for key, value in dic.items():
        c *= (value+1)
    c -= 1
    """
    c += 2**len(dic.keys())-1
    #print(c)
    #c += S
    for key, value in dic.items():
        if value > 1:
            #c -= (value-1)
            c += 2**(len(dic.keys()))-1
            #print(c)
    #for key, value in dic.items():
    for key, value in dic.items():
        if value > 1:
            if len(dic.keys()) != S:
                c -= 2**(S-len(dic.keys())-1)
    """
            #print(c)
        #else:
    #c += (S-len(dic.keys()))
    """
    s_N = sorted(N)
    for i in range(S-1):
        if s_N[i] != s_N[i+1]:
            c += 2**(i+2)
    """
    """
    for key, value in dic.items():
        if value > 1:
            c += 2**(len(dic.items())-value)
        else:
            c += 2**(len(dic.items())-value)
    """
    #combinations_count(len(, r)

    return c % (10**9 + 7)


def main():
    input_line = stdin.readlines()
    answer = problem_a(input_line)
    print(answer)


if __name__ == '__main__':
    main()
h, w, k = map(int, input().split())
m = []
for i in range(h):
    m.append(list(input()))

ans = []
for i in range(h):
    ans.append([0 for _ in range(w)])

if m[0][0] == '#':
    c = 0
else:
    c = 1
emp = []
for i in range(h):
    s1 = 0
    s = m[i].count('#')
    # 行に一つもいちごがない
    if s == 0:
        emp.append(i)
        continue
    for j in range(w):
        flag = 0
        if m[i][0] == '#':
            if m[i][j] == '#':
                if s1 < s and c < k:
                    s1 += 1
                    c += 1
            ans[i][j] = c
        else:
            ans[i][j] = c
            if m[i][j] == '#':
                flag = 1
                if s1 < s-1 and c < k:
                    s1 += 1
                    c += 1
    if i != h-1 and m[i+1][0] != '#':
        c += 1

for e in emp:
    for j in range(w):
        idx = []
        if e == 0:
            for i1 in range(1, h):
                if ans[i1][0] != 0:
                    idx = ans[i1]
                    break
            ans[e][j] = idx[j]
        elif e == h-1:
            for i1 in list(range(h-1))[::-1]:
                if ans[i1][0] != 0:
                    idx = ans[i1]
                    break
            ans[e][j] = idx[j]
        else:
            for i1 in range(e+1, i+1):
                if ans[i1][0] != 0:
                    idx = ans[i1]
                    break
            ans[e][j] = idx[j]

for i in ans:
    print(' '.join(map(str, i)))


### FIXED CODE ###

h, w, k = map(int, input().split())
m = []
for i in range(h):
    m.append(list(input()))

ans = []
for i in range(h):
    ans.append([0 for _ in range(w)])

if m[0][0] == '#':
    c = 0
else:
    c = 1
emp = []
for i in range(h):
    s1 = 0
    s = m[i].count('#')
    # 行に一つもいちごがない
    if s == 0:
        emp.append(i)
        continue
    for j in range(w):
        flag = 0
        if m[i][0] == '#':
            if m[i][j] == '#':
                if s1 < s and c < k:
                    s1 += 1
                    c += 1
            ans[i][j] = c
        else:
            ans[i][j] = c
            if m[i][j] == '#':
                flag = 1
                if s1 < s-1 and c < k:
                    s1 += 1
                    c += 1
    if i != h-1 and m[i+1][0] != '#':
        c += 1

if 0 in emp:
    for j in range(w):
        for i1 in range(1, h):
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[0][j] = idx[j]
    emp.remove(0)
if h-1 in emp:
    for j in range(w):
        for i1 in list(range(h-1))[::-1]:
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[h-1][j] = idx[j]
    emp.remove(h-1)
for e in emp:
    for j in range(w):
        idx = []
        for i1 in range(e+1, h):
            if ans[i1][0] != 0:
                idx = ans[i1]
                break
        ans[e][j] = idx[j]

for i in ans:
    print(' '.join(map(str, i)))
a=input()
a_l=len(a)
b=input()
b_l=len(b)
c=input()
c_l=len(c)
def check(s1,s2):
    l1=len(s1)
    l2=len(s2)
    ret=[0]*(l1+l2-1)
    for i in range(l1+l2-1):
        flag=True
        if i-l2+1<0:
            for j in range(i+1):
                if s1[j]!="?" and s2[l2-i+j-1]!="?" and s1[j]!=s2[l2-i+j-1]:
                    flag=False
                    break
        elif i-l2+1>=0 and i<=l1-1:
            for j in range(l2):
                if s1[i-l2+j+1]!="?" and s2[j]!="?" and s1[i-l2+j+1]!=s2[j]:
                    flag=False
                    break
        else:
            for j in range(l1+l2-i-1):
                if s1[i-l2+j+1]!="?" and s2[j]!="?" and s1[i-l2+j+1]!=s2[j]:
                    flag=False
                    break
        ret[i]=flag
    return ret
ab=check(a,b)
ab_l=len(ab)
ac=check(a,c)
ac_l=len(ac)
bc=check(b,c)
bc_l=len(bc)
ans=a_l+b_l+c_l
for i in range(-3000,ab_l+3000):
    if i<0 or i>=ab_l or ab[i]:
        for j in range(-3000,ac_l+3000):
            if j<0 or j>=ac_l or ac[j]:
                if (0<=j-i+b_l+1<bc_l and bc[j-i+b_l+1]) or j-i+b_l+1<0 or j-i+b_l+1>=bc_l:
                    l=max(a_l-1,i,j)-min(0,i-b_l+1,j-c_l+1)+1
                    ans=min(ans,l)
print(ans)

### FIXED CODE ###

k=int(input())
l=[1 ,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])
n=int(input())
d=list(map(int,input().split()))
s=0
for i in range(n):
    for j in range[i+1:]:
        s += d[i]*d[j]
print(s)

### FIXED CODE ###


n=int(input())
d=list(map(int,input().split()))
s=0
for i in range(n):
    for j in range(i+1,n):
        s += d[i]*d[j]
print(s)
import sys
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        if (N*h*n)%(4*h*n-N*(h+n)) == 0:
            w = N*h*n // (4*h*n-N*(h+n))
            if w <= 0:continue
            if h*n*w % N == 0:
                print(h,n,w)
                sys.exit()
        
print(-1)

### FIXED CODE ###

import sys
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        tmp = 4*h*n-N*(h+n)
        if tmp == 0:continue
        if (N*h*n)%(tmp) == 0:
            w = N*h*n // (tmp)
            if w <= 0:continue
            if h*n*w % N == 0:
                print(h,n,w)
                sys.exit()
        
print(-1)
import sys

def solve():
    input = lambda: sys.stdin.readline().rstrip()
    sys.setrecursionlimit(10 ** 7)
    mod = 10 ** 9 + 7

    def comb(n, r):
        if r > n: return 0
        return fac[n] * inv[r] * inv[n - r] % mod

    def dfs(v, Pa=-1):
        for u in to[v]:
            if u == Pa: continue
            dfs(u, v)
            size[v] += size[u]
            dp[v] *= dp[u] % mod
            dp[v] *= inv[size[u]] % mod
        dp[v] *= fact[size[v]] % mod
        size[v] += 1

    def bfs(v, Pa=-1, P_val=1, P_sz=0):
        ans[v] = P_val * dp[v] * comb(n - 1, P_sz) % mod
        for u in to[v]:
            if u == Pa: continue
            val = ans[v] * INV(dp[u] * comb(n - 1, size[u])) % mod
            bfs(u, v, val, n - size[u])

    n = int(input())
    to = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        to[a].append(b)
        to[b].append(a)

    fac = [1] * (n + 2)
    inv = [1] * (n + 2)

    for i in range(2, n + 1):
        fac[i] = fac[i - 1] * i % mod
    INV = lambda x: pow(x, mod - 2, mod)
    inv[n] = INV(fac[n])
    for i in range(n - 1, 1, -1):
        inv[i] = inv[i + 1] * (i + 1) % mod

    dp = [1] * n
    size = [0] * n
    ans = [0] * n

    dfs(0)
    bfs(0)
    print(*ans, sep='\n')

if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys

def solve():
    input = lambda: sys.stdin.readline().rstrip()
    sys.setrecursionlimit(10 ** 7)
    mod = 10 ** 9 + 7

    def comb(n, r):
        if r > n: return 0
        return fac[n] * inv[r] * inv[n - r] % mod

    def dfs(v, Pa=-1):
        for u in to[v]:
            if u == Pa: continue
            dfs(u, v)
            size[v] += size[u]
            dp[v] *= dp[u] % mod
            dp[v] *= inv[size[u]] % mod
        dp[v] *= fac[size[v]] % mod
        size[v] += 1

    def bfs(v, Pa=-1, P_val=1, P_sz=0):
        ans[v] = P_val * dp[v] * comb(n - 1, P_sz) % mod
        for u in to[v]:
            if u == Pa: continue
            val = ans[v] * INV(dp[u] * comb(n - 1, size[u])) % mod
            bfs(u, v, val, n - size[u])

    n = int(input())
    to = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        to[a].append(b)
        to[b].append(a)

    fac = [1] * (n + 2)
    inv = [1] * (n + 2)

    for i in range(2, n + 1):
        fac[i] = fac[i - 1] * i % mod
    INV = lambda x: pow(x, mod - 2, mod)
    inv[n] = INV(fac[n])
    for i in range(n - 1, 1, -1):
        inv[i] = inv[i + 1] * (i + 1) % mod

    dp = [1] * n
    size = [0] * n
    ans = [0] * n

    dfs(0)
    bfs(0)
    print(*ans, sep='\n')

if __name__ == '__main__':
    solve()
n = (int)(input)
print((n-1)*n)//2

### FIXED CODE ###

n = (int)(input())
print((n-1)*n//2)
n = int(input())

if n == 100000 :
    ans = 101009
elif 10000 <= n <= 99999 :
    ans = n - 10000 + 1 + 1000 + 9
elif 1000 <= n <= 9999 :
    ans = 1009
elif 100 <= n <= 999 :
    ans = n - 100 + 1 + 9
elif 10 <= n < 99 :
    ans = 9 
elif 1 <= n <= 9 :
    ans = n

print(ans)


### FIXED CODE ###

n = int(input())
c = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1 :
        c += 1

print(c)
N = input()
print("Yes" if N%(sum(map(int, N))) == 0 else "No")

### FIXED CODE ###

N = input()
print("Yes" if int(N)%(sum(map(int, N))) == 0 else "No")
# -*- coding: utf-8 -*-

a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input())

k = b - a
l = b*w + a*w

if (k < l):
    flag = False

if (flag):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

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

a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input())

k = b - a
flag = False

if k >= 0:
    l = T*v - T*w 
    if (k <= l):
        flag = True

if k < 0:
    k = a - b
    l = T*v - T*w
    if (k <= l):
        flag = True


if (flag == True):
    print('YES')
else:
    print('NO')
n = int(input())
a = list(map(int,input().split()))
b = max(a)-min(b)
print(b)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
print(max(a)-min(a))
n, x, t = map(int, input().split())
if n%x == 0:
  print(n*t/x)
else:
  print(((int(n/x)+1)*t)

### FIXED CODE ###

n, x, t = map(int, input().split())
if n%x==0:
  print((n//x)*t)
else:
  print( ((n//x)+1)*t )
N = input()
A = input()
print(N**2-A)

### FIXED CODE ###

N = int(input())
A = int(input())
print(N**2-A)
N = int(input())
S = [input() for i in range(N)]
from collections import defaultdict
encodes = [hash(tuple(sorted(list(s)))) for s in S]
hash_table = defaultdict(int)
for encode in encodes:
  hash_table[encode] += 1
import math
c_list = [int(math.factorial(v)/math.factorial(2)) for v in hash_table.values()]
count = sum(c_list)
print(count)

### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]
d = {}
S_trans = [''.join(sorted(list(s))) for s in S]
count = 0
for s in S_trans:
  if s in d:
    count += d[s]
    d[s] += 1
  else:
    d[s] = 1
print(count)
a = []
i = 0

s = int(input())

a.append(s)

while True:
    if(a[i] % 2 == 0):
        if(a[i] / 2 != 0):
        	ans = int(a[i] / 2)
        else:
            ans = 0
        if ans in a:
            print(i + 2)
            break
       	a.append(ans)
    else:
        anss = int(a[i] * 3 + 1)
        if anss in a:
            print(i + 2)
            break
        a.append(anss)

    i += 1

### FIXED CODE ###

AB, BC, CA = map(int, input().split())

a = int(AB * BC / 2)

print(str(a))
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

max = 0
for i in range(n-k+1):
  j = i
  s = 0
  for j in range(k):
    s += e[j]
    j += 1
  if max < s:
    max = s
    
print((max+k)/1.0)


### FIXED CODE ###

n,k = map(int, input().split())
p = [int(e) for e in input().split()]
s = sum(p[0:k])
max = s
for i in range(n-k):
  s = s - p[i] + p[i+k]
  if max < s:
    max = s
    
ex = (max+k)/2.0
print(ex)
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
A, B, K=map(int,input().split())
D = cf(A,B)
print(D[-K])


### FIXED CODE ###

a,b,k=map(int,input().split())
check=0
m=min(a,b)
for i in range(m,0,-1):
    if a%i==0 and b%i==0:
        check+=1
        if check==k:
            print(i)
            break
n = int(input())
mod = 10**9+7
a = [1]*16
no = [0,0]
for _ in range(n-2):
  b = [0]*16
  b[0] = a[0] + a[4] + a[8] + a[12]
  b[1] = a[0] + a[4] + a[12]
  b[2] = a[0] + a[4] + a[8] + a[12]
  b[3] = a[0] + a[4] + a[8] + a[12]
  b[4] = a[1] + a[5] + a[9] + a[13]
  b[5] = a[1] + a[5] + a[9] + a[13]
  b[6] = a[5] + a[9] + a[13]
  b[7] = a[1] + a[5] + a[9] + a[13]
  b[8] = a[2] + a[6] + a[9] + a[14]
  b[9] = a[6] + a[9] + a[14] - no[0] - no[1]
  b[10] = a[2] + a[6] + a[9] + a[14]
  b[11] = a[2] + a[6] + a[9] + a[14]
  b[12] = a[3] + a[7] + a[10] + a[15]
  b[13] = a[3] + a[7] + a[10] + a[15] - no[1]
  b[14] = a[3] + a[7] + a[10] + a[15]
  b[15] = a[3] + a[7] + a[10] + a[15]
  no[0] = a[2]
  no[1] = a[3]
  a = b
  for i in range(16):
    a[i] %= mod
print(sum(a))


### FIXED CODE ###

print(input().translate(str.maketrans("ATGC","TACG")))
# coding: utf-8
# Your code here!
import sys
num =[]
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,4):
    if num.count(i)=3:
        print("NO")
        sys.exit()
print("YES")


### FIXED CODE ###

# coding: utf-8
# Your code here!
num =[]
ans =0
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,5):

    if num.count(i)==3:
        ans +=1
if ans>0:
    print("NO")
else:
    print("YES")
# Ai>=Bi 出来るならそのままにする
# Ai < Bi 仕方ないので溢れたぶんを使う
# 「変更したAi」の最小値が欲しいので、使うのは余ってるやつが多い順に使ったほうがいい

n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))

lack, lack_i = 0, []
extra, extra_i = 0, []
for i in range(n):
    if arr[i] < brr[i]:
        lack += brr[i] - arr[i]
        lack_i.append([i, brr[i] - arr[i]])
    else:
        extra += arr[i] - brr[i]
        extra_i.append([i, arr[i] - brr[i], False])

if lack > extra:
    print(-1)
    exit()

# 大量に余っているやつから優先的に使う
extra_i = list(sorted(extra_i, key=lambda x: x[1], reverse=True))
ans = 0

l_i = 0
e_i = 0

while True:
    if l_i >= len(lack_i):
        break
    while True:
        if lack_i[l_i][1] <= extra_i[e_i][1]:
            extra_i[e_i][2] = True  # 一回でも使用した
            ans += 1  #
            extra_i[e_i][1] -= lack_i[l_i][1]
            break
        else:
            extra_i[e_i][2] = True  # 一回でも使用した
            e_i += 1
            lack_i[l_i][1] -= extra_i[e_i][1]
            extra_i[e_i][1] = 0
        if e_i > len(extra_i):
            print(-1)
            exit()
            break  # ここにくるときがよくわからんけど
    l_i += 1

bonus = len(list(filter(lambda x: x[2] == True, extra_i)))
print(ans + bonus)


### FIXED CODE ###

# にぶたんが失敗したので両端からしゃくとりするような感じでやってみる
# 差分でソートして大きく足りないものは大きく余ってるやつをぶつける

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
D = []
pre_ans = 0  # 確実に変えなくてはいけないやつ
for i in range(N):
    if A[i] != B[i]:
        D.append(A[i] - B[i])
        if A[i] < B[i]:
            pre_ans += 1
D = sorted(D)

used = 0
tmp = 0
# print(D)
l, r = 0, len(D)
while r - l > 1:
    # print("now tmp: {}".format(tmp))
    if tmp + D[l] < 0:
        # 新たに借りる
        r -= 1
        used += 1
        tmp += D[r]
    tmp += D[l]
    l += 1
print(used + pre_ans)
import math

A,B,C,D=map(int,input().split())
num=B-A
numC=num//C
numD=num//D
numCD=int(num//(C*D/math.gcd(C,D)))
ans=num-numC-numD+numCD
print(ans)

### FIXED CODE ###

import fractions

def div(a,b,c):
    val=b//c-(a-1)//c
    return val

A,B,C,D=map(int,input().split())
numC=div(A,B,C)
numD=div(A,B,D)
lcm=int(C*D/(fractions.gcd(C,D)))
numCD=div(A,B,lcm)
ans=B-A+1-numC-numD+numCD
print(ans)
A,B = map(int,input())

print(B//A +1)

### FIXED CODE ###

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

x = math.ceil(1+(B-A)/(A-1))

print(x)
def fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
ans = fib(a[0])
try:
  for j in range(1,m):
    if m == 1:
        continue
    elif a[j] == a[j-1]+1:
        ans = 0
    else:
        ans *= fib(a[j]-a[j-1]-1)
  ans *= fib(n-a[m-1])
except:
  ans = 0
print(ans%1000000007)


### FIXED CODE ###

def fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

n,m = map(int,input().split())
if m != 0:
  a = [int(input()) for i in range(m)]
  ans = fib(a[0])
  for j in range(1,m):
    if m == 1:
        continue
    elif a[j] == a[j-1]+1:
        ans = 0
    else:
        ans *= fib(a[j]-a[j-1]-1)
  ans *= fib(n-a[m-1])
else:
  ans = fib(n+1)
print(ans%1000000007)
import math
A, B, H, M = [int(i) for i in input().split()]
h = H* 2*math.pi/12 #rad
m = M* 2*math.pi/60 #rad
#print(h, "\n", m)
def kyori(a,b,c,d):
    return math.sqrt(a**2+b**2-2*a*b*math.cos(c-d))

print(kyori(A,B,h,m))

### FIXED CODE ###

N = input()

N1= int(N[-1])
#print(N1)

if N1 in {2,4,5,7,9}:
    print("hon")
elif N1 in {0,1,6,8}:
    print("pon")
else:
    print("bon")
R,G,B,N=map(int,input().split())

tmp=0
for i in range(N//R+1):
  for j in range((N-R*i)//G+1):
    if and (N-(R*i+G*j))%B==0:
      tmp+=1
print(tmp)


### FIXED CODE ###

R,G,B,N=map(int,input().split())

tmp=0
for i in range(N//R+1):
  for j in range((N-R*i)//G+1):
    if (N-(R*i+G*j))%B==0:
      tmp+=1
print(tmp)
h,w = map(int,input().split())
s = [input() for _ in range(h)]

ans = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            dis = [[-1] * w for _ in range(h)]
            dis[i][j] = 0
            q = [(i,j)]
            while q:
                l0,l1 = q.pop(0)
                if l0 > 0:
                    if s[l0-1][l1] == '.':
                        if dis[l0-1][l1] > dis[l0][l1] + 1 or dis[l0-1][l1] == -1:
                            dis[l0-1][l1] = dis[l0][l1] + 1
                            q.append((l0-1,l1))
                if l0 < h - 1:
                    if s[l0+1][l1] == '.':
                        if dis[l0+1][l1] > dis[l0][l1] + 1 or dis[l0+1][l1] == -1:
                            dis[l0+1][l1] = dis[l0][l1] + 1
                            q.append((l0+1,l1))
                if l1 > 0:
                    if s[l0][l1-1] == '.':
                        if dis[l0][l1-1] > dis[l0][l1] + 1 or dis[l0][l1-1] == -1:
                            dis[l0][l1-1] = dis[l0][l1] + 1
                            q.append((l0,l1-1))
                if l1 < w - 1:
                    if s[l0][l1+1] == '.':
                        if dis[l0][l1+1] > dis[l0][l1] + 1 or dis[l0][l1+1] == -1:
                            dis[l0][l1+1] = dis[l0][l1] + 1
                            q.append((l0,l1+1))
        dis_max = 0
        for k in dis:
            dis_max = max(max(k), dis_max)
        ans = max(dis_max,ans)

print(ans)


### FIXED CODE ###

h,w = map(int,input().split())
s = [input() for _ in range(h)]

ans = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            dis = [[-1] * w for _ in range(h)]
            dis[i][j] = 0
            q = [(i,j)]
            while q:
                l0,l1 = q.pop(0)
                if l0 > 0:
                    if s[l0-1][l1] == '.':
                        if dis[l0-1][l1] > dis[l0][l1] + 1 or dis[l0-1][l1] == -1:
                            dis[l0-1][l1] = dis[l0][l1] + 1
                            q.append((l0-1,l1))
                if l0 < h - 1:
                    if s[l0+1][l1] == '.':
                        if dis[l0+1][l1] > dis[l0][l1] + 1 or dis[l0+1][l1] == -1:
                            dis[l0+1][l1] = dis[l0][l1] + 1
                            q.append((l0+1,l1))
                if l1 > 0:
                    if s[l0][l1-1] == '.':
                        if dis[l0][l1-1] > dis[l0][l1] + 1 or dis[l0][l1-1] == -1:
                            dis[l0][l1-1] = dis[l0][l1] + 1
                            q.append((l0,l1-1))
                if l1 < w - 1:
                    if s[l0][l1+1] == '.':
                        if dis[l0][l1+1] > dis[l0][l1] + 1 or dis[l0][l1+1] == -1:
                            dis[l0][l1+1] = dis[l0][l1] + 1
                            q.append((l0,l1+1))
            dis_max = 0
            for k in dis:
                dis_max = max(max(k), dis_max)
            ans = max(dis_max,ans)

print(ans)
i = input()
print(24+i)

### FIXED CODE ###

print("{}".format(24 - int(input()) + 24))
def alice(x, y):
    return turn(x, y)

def brown(x, y):
    return turn(x, y)

def turn(x, y):
    a = 0
    if x < y or x == y:
        a = y / 2
        y = y - a * 2
        x = x + a
    else:
        a = x / 2
        x = x - a * 2
        y = y + a
    if a == 0:
        return [False, x, y]
    return [True, x, y]

nums = input().split(" ")
x = int(nums[0])
y = int(nums[1])
while True:
    result, x, y = alice(x, y)
    if result == False:
        print('Brown')
        break
    result, x, y = brown(x, y)
    if result == False:
        print('Alice')
        break

### FIXED CODE ###

str = input()
strs = str.split(" ")
ans = ""
for str in strs:
    ans = ans+str[0].upper()
print(ans)