Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

while True:
    n=input()
    if n==0:
        break
    dp=[[0 for i in range(n)]for j in range(n)]
    flag0=0
    for i in range(n):
        j=0
        for c in raw_input():
            if c == ".":
                dp[i][j]=1
                flag0=1
            j+=1
    if flag0==0:
        print 0
    else:
        solve=1
        while True:
            flag=0
            for y in xrange(n-1):
                for x in xrange(n-1):
                    if dp[y][x]==solve and dp[y+1][x]==solve and\
                       dp[y][x+1]==solve and dp[y+1][x+1]==solve:
                        dp[y][x]=solve+1
                        flag=1
            if flag==0:
                break
            solve+=1
        print solve

### FIXED CODE ###

while True:
    n=input()
    if n==0:
        break
    dp=[[0 for i in range(n+1)]for j in range(n+1)]
    for i in range(1,n+1):
        j=0
        line=" "+raw_input()
        for c in line:
            if c == ".":
                dp[i][j]=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1
            j+=1
    allmax=0
    for i in range(n+1):
        if allmax<max(dp[i]):
            allmax=max(dp[i])
    print allmax
### BUGGY CODE ###

import collections
n = str(input())
ans= 0
t=[0]*2019
t[0]=1
for i in range(0,len(n)):
        k = int(n[i:len(n)]) % 2019
        t[k] +=1
for i in t:
    ans += i *(i-1) /2
print(int(ans))


### FIXED CODE ###

import collections
n = str(input())
ans,m,div = 0,0,[]
for i,j in enumerate(reversed(n)):
    m=(m+int(j)*pow(10,i,2019))%2019
    div.append(m)
div.append(0)
c = collections.Counter(div)
values, counts = zip(*c.most_common())
for i in range(0,len(counts)):
    ans += counts[i] *(counts[i]-1) /2
print(int(ans))
### BUGGY CODE ###

import itertools
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(len(l)-2):
  for j in range(i+1,len(l)):
    for k in range(j+1,len(l)):
      if l[k] < l[i]+l[j]:
        ans += 1
      else:
        break

print(ans)

### FIXED CODE ###

import itertools
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(len(l)-2):
  for j in range(i+1,len(l)):
    k = bisect.bisect_left(l, l[i]+l[j])
    if k > j:
      ans += k - j -1

print(ans)
### BUGGY CODE ###

from collections import deque
H, W, M = map(int, input().split())
grid = [[0 for _ in range(W)] for _ in range(H)]
counth = [0 for _ in range(H)]
countw = [0 for _ in range(W)]
for _ in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  grid[h][w] = 1
  counth[h] += 1 
  countw[w] += 1


maxh = max(counth)
maxw = max(countw)

counth = deque(counth)
countw = deque(countw)

index_h = deque([])
index_w = []
for k in range(H):
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)
lenh = len(index_h)

for k in range(W):
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)
    lenw = len(index_w)
    if lenh*lenw > M:
      print(maxh + maxw)
      exit()    

ans = maxh + maxw - 1
for h in index_h:
  for w in index_w:
    if grid[h][w] == 0:
      ans += 1
      break
  else:
    continue
  break
print(ans)

### FIXED CODE ###

from collections import deque
H, W, M = map(int, input().split())
bomb = []
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  bomb.append(h+ w*H)
  counth[h] += 1 
  countw[w] += 1
counth = deque(counth)
countw = deque(countw)

def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            #return mid
            return True
        if guess > item:
            high = mid -1
        else:
            low = mid + 1

    #return None
    return False


maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = []
for k in range(H):
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)

for k in range(W):
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)

ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)


if lenh*lenw > M:
  ans += 1
else:
  bomb.sort()
  kouho = []
  for i in range(lenh):
    h = index_h.pop()
    for j in range(lenw):
      w = index_w[j]
      kouho.append(h+ H*w)
  for K in kouho:
    if binary_search(bomb, K):
      continue
    else:
      ans += 1
      break
    
print(ans)
### BUGGY CODE ###

# pylint: disable=invalid-name
# pylint: disable=missing-docstring


def main():
    N, K = map(int, input().split())
    H = [0] + [int(x) for x in input().split()]
    DP = [[-1 for _ in range(K + 1)] for _ in range(N + 1)]
    DP[0] = [0 for _ in range(K + 1)]
    for i in range(1, N + 1):
        for j in range(K + 1):
            for k in range(max(i - j - 1, 0), i):
                previous = DP[k][j - (i - k - 1)]
                if previous == -1:
                    continue

                if DP[i][j] == -1 or previous + max(H[i] - H[k], 0) < DP[i][j]:
                    DP[i][j] = previous + max(H[i] - H[k], 0)

                if j > 0 and DP[i][j - 1] != -1 and DP[i][j - 1] < DP[i][j]:
                    DP[i][j] = DP[i][j - 1]
                # print('i {} j {} k {} j - (i - k - 1) {} DP_targ {} DP {}'.
                #       format(i, j, k, j - (i - k - 1),
                #              previous + max(H[i] - H[k], 0), DP[i][j]))
    ans = -1
    for i in range(N + 1):
        if K < (N - i):
            continue
        if ans == -1 or DP[i][min(K - (N - i), K)] < ans:
            ans = DP[i][min(K - (N - i), K)]
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# pylint: disable=invalid-name
# pylint: disable=missing-docstring


def main():
    N, K = map(int, input().split())
    H = [0] + [int(x) for x in input().split()]
    DP = [[-1 for _ in range(K + 1)] for _ in range(N + 1)]
    DP[0] = [0 for _ in range(K + 1)]
    for i in range(1, N + 1):
        for j in range(K + 1):
            for k in range(max(i - j - 1, 0), i):
                previous = DP[k][j - (i - k - 1)]
                if previous == -1:
                    continue

                if DP[i][j] == -1 or previous + max(H[i] - H[k], 0) < DP[i][j]:
                    DP[i][j] = previous + max(H[i] - H[k], 0)

                if j > 0 and DP[i][j - 1] != -1 and DP[i][j - 1] < DP[i][j]:
                    DP[i][j] = DP[i][j - 1]
                # print('i {} j {} k {} j - (i - k - 1) {} DP_targ {} DP {}'.
                #       format(i, j, k, j - (i - k - 1),
                #              previous + max(H[i] - H[k], 0), DP[i][j]))
    ans = -1
    for i in range(N + 1):
        if K < (N - i):
            continue
        if ans == -1 or DP[i][min(K - (N - i), K)] < ans:
            ans = DP[i][min(K - (N - i), K)]
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
for i in range(1, n+1):
    if i != n:
        print(a.index(i)+1, end=" ")
    else:
        print(a.index(i)+1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i, j in enumerate(a):
    b[j-1] = i+1

print(*b)
### BUGGY CODE ###

n,k=map(int,input().split())
s=list(input())
if k>=n:
    print(min(s)*n)
else:
    for i in range(min(k,5000)):
        t=list(reversed(s))
        u=s+t
        u.reverse()
        uu=[]
        for j in range(n+1):
            uu.append(u[j:j+n])
            uu.sort()
            s=list(reversed(uu[0]))
    print("".join(list(reversed(s))))


### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
l=0
c=0
for i in range(n):
    if s[i]==min(s):
        c+=1
        l=max(l,c)
    else:
        c=0
import sys
input=sys.stdin.readline
s.reverse()
if (2**(k-1))*l>n:
    print(min(s)*n)
else:
    for i in range(min(k,13)):
        t=list(reversed(s))
        u=t+s
        uu=u[:n]
        for j in range(1,n+1):
            x=u[j:j+n]
            if uu>x:
                uu=x
        s=uu
    print("".join(s))
### BUGGY CODE ###

import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    N, C = list(map(int, input().split()))
    a = []
    check_set = set()
    for _ in range(N):
        s, t, c = list(map(int, input().split()))
        a.append((s - 0.5, s, t, c))
        check_set.add((s - 0.5, c))
        check_set.add((s, c))
        check_set.add((t - 0.01, c))

    ans = 0
    for t1, c1 in check_set:
        total = 0
        for sp2, s2, t2, c2 in a:
            if c1 == c2:
                total += s2 <= t1 <= t2
            else:
                total += sp2 <= t1 <= t2
        ans = max(ans, total)
    print(ans)

    
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


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

    s_t_c = []
    for i in range(N):
        s, t, c = list(map(int, input().split()))
        s_t_c.append((s, t, c))

    ans = [0] * (2 * 10 ** 5 + 2)
    for i in range(1, C + 1):
        dp = [0] * (2 * 10 ** 5 + 2)

        for s, t, c in s_t_c:
            if c == i:
                dp[s * 2 - 1] += 1
                dp[t * 2] -= 1
        for j in range(1, len(dp)):
            dp[j] += dp[j - 1]

        for j in range(len(dp)):
            ans[j] += dp[j] > 0

    print(max(ans))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
h = list(map(int,input().split()))

ans="Yes"

for i in range(n-1):
    a=n-i-1
    for j in range(a):
        if(h[i]>=h[i+j+1]+2):
            ans="No"

print(ans)

### FIXED CODE ###

import sys
import bisect
input = sys.stdin.readline

def main():
    n=int(input())
    h = list(map(int,input().split()))

    ans="Yes"
    m=0

    for i in range(n):
        if(m>=h[i]+2):
            ans="No"
        else:
            m=max(m,h[i])
        if(ans=="No"):
            break
        
    print(ans)
    
main()
### BUGGY CODE ###

count = input()
numbers = map(int, input().split(' '))

counter = 0
while True:
  tmp = 0
  for item in numbers:
    tmp = tmp + item % 2
  if tmp > 0:
    break
  counter += 1
  numbers = [item / 2 for item in numbers]
print(counter)

### FIXED CODE ###

count = int(input())
numbers = [int(num) for num in input().split()]

counter = 0
while True:
  tmp = 0
  for item in numbers:
    tmp += item % 2
  if tmp > 0:
    break
  counter += 1
  numbers = [item / 2 for item in numbers]
print(counter)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from random import randint
from math import gcd


def solve(N: int):
    # zの条件
    # - Nの約数
    # - 素数pのn乗
    # - 過去に選択したzと被らない
    n = N
    ds = make_divisors(n)
    print(ds)
    used = []
    while(True):
        count = len(used)
        for d in ds:
            if d in used:
                continue
            p, k = primePower(d)
            print(p)
            if p == 0:
                continue
            n /= d
            used.append(d)
            break

        if count == len(used):
            print(count)
            return
    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def findWitness(n, k=5): # miller-rabin
    s, d = 0, n-1
    while d % 2 == 0:
        s, d = s+1, d/2
    for i in range(k):
        a = randint(2, n-1)
        x = pow(a, d, n)
        if x == 1 or x == n-1: continue
        for r in range(1, s):
            x = (x * x) % n
            if x == 1: return a
            if x == n-1: break
        else: return a
    return 0


def primePower(n):
    def checkP(n, p):
        k = 0
        while n > 1 and n % p == 0:
            n, k = n / p, k + 1
        if n == 1: return p, k
        else: return 0, 0

    if n % 2 == 0: return checkP(n, 2)
    q = n
    while True:
        a = findWitness(q)
        if a == 0: return checkP(n, q)
        d = gcd(pow(a,q,n)-a, q)
        if d == 1 or d == q: return 0, 0
        q = d


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int):
    # zの条件
    # - Nの約数
    # - 素数pのn乗
    # - 過去に選択したzと被らない

    def f(x):
        cnt = 0
        for i in range(1, x + 1):
            x -= i
            if x < 0:
                break
            cnt += 1
        return cnt

    print(sum([f(p[1]) for p in factorize(N)]))
    return


def factorize(n: int):
    """nの素因数分解を求める"""
    res = []
    for i in range(2, int(n ** 0.5//1 + 2)):
        if n % i:
            continue
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        res.append([i, s])
    if n != 1:
        res.append([n, 1])
    return res


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

N=int(input())
X=[]
places=[]
for i in range(N):
    inp=input()
    X.append(inp)
    places.append(X.count(inp))
ans=[]
for j in range(N):
    if places[j]==max(places):
        ans.append(X[j])
ans.sort()
for a in ans:
    print(a)

### FIXED CODE ###

import collections
N=int(input())
X=[input().strip() for i in range(N)]

cc=collections.Counter(X)
maximum=max(cc.values())

ans=sorted([ss[0] for ss in cc.items() if ss[1]==maximum])
print(*ans)
### BUGGY CODE ###

def main():
    n,k = map(int, input().split())
    a =  list(map(int, input().split()))

    ans = [1]
    for _ in range(n):
        if a[ans[-1]-1] in ans:
            start = ans.index(a[ans[-1]-1])
            break
        ans.append(a[ans[-1]-1])

    if k > start:
        index = (k - start) % (len(ans) - start) + start
        t = ans[index]
    else:
        t = ans[k]
    return print(t)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    a =  list(map(int, input().split()))

    path = [1]
    for _ in range(n-1):
        path.append(a[path[-1]-1])

    if k > n:
        start = path.index(path[-1])
        index = (k - start) % (len(path) - start - 1) + start
        t = path[index]
    else:
        t = path[k]
    return print(t)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
n,q=map(int,input().split())
graph=[[] for _ in range(n+1)]
ab=[list(map(int,input().split())) for _ in range(n-1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
px=[list(map(int,input().split())) for _ in range(q)]
seen=[0]*(n+1)
ans=[0]*(n+1)
for p,x in px:
    ans[p]+=x
def dfs(i):
    seen[i]=1
    for li in graph[i]:
        if seen[li]==0:
            ans[li]+=ans[i]
            dfs(li)
dfs(1)
print(' '.join(map(str,ans[1:])))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
def main():
    n,q=map(int,input().split())
    graph=[[] for _ in range(n+1)]
    ab=[list(map(int,input().split())) for _ in range(n-1)]
    for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
    px=[list(map(int,input().split())) for _ in range(q)]
    seen=[0]*(n+1)
    ans=[0]*(n+1)
    for p,x in px:
        ans[p]+=x
    def dfs(i):
        seen[i]=1
        for li in graph[i]:
            if seen[li]==0:
                ans[li]+=ans[i]
                dfs(li)
    dfs(1)
    print(' '.join(map(str,ans[1:])))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
m = 0
ans= []
for i in reversed(range(n)):
  z = 0
  for a in ans:
    if a%(i+1)==0:
      z += 1
  if (z+A[i])%2==1:
    ans.append(i+1)
    m+= 1
  else:
    pass
print(m)
print(*ans)
    
  

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
ans= []
B = [0]*n
for i in reversed(range(n)):
  if sum(B[i::i+1])%2!=A[i]:
    ans.append(i+1)
    B[i]+= 1
print(len(ans))   
print(*ans)
### BUGGY CODE ###

n=int(input())
list=[]
for i in range(n):
  list.append(input())
s=[]
for i in range(n):
  if list[i] not in s:
    s.append(list[i])
print(len(s))



### FIXED CODE ###

from collections import Counter
n=int(input())
list=[]
for i in range(n):
  list.append(input())
a=Counter(list)
print(len(a))
### BUGGY CODE ###

N,M = map(int,input().split())
boat = [list(map(int,input().split())) for _ in range(M)]
flag = 0
for i in range(2,N):
    if [1,i] in boat and [i,N] in boat:
        flag = 1
print("IMPOSSIBLE" if flag == 0 else "POSSIBLE")

### FIXED CODE ###

n,m=map(int,input().split())
A=set()
B=set()
for i in range(m):
  a,b=input().split()
  if a=="1":
    A.add(b)
  if b==str(n):
    B.add(a)
print("POSSIBLE" if A&B else "IMPOSSIBLE")
### BUGGY CODE ###

s=input()
k=int(input())
x=[]
for i in range(len(s)):
     for j in range(1,len(s)-i+1):
          x.append(s[i:i+j])
x=list(set(x))
x.sort()
print(x[k-1])

### FIXED CODE ###

s=input()
k=int(input())
x=set()
for i in range(len(s)):
     for j in range(1,min(len(s)-i+1,k+1)):
          x.add(s[i:i+j])
x=list(x)
x.sort()
print(x[k-1])
### BUGGY CODE ###

a = list(map(int, input().split()))
r = a[0]
g = a[1]
b = a[2]
n = a[3]
c = 0

for i in range(n+1):
    for j in range(n+1):
        k = (n - (r*i + g*j))//b
        if k >= 0:
            if n == r*i + g*j + b*k:
                c += 1
print(c)

### FIXED CODE ###

a = list(map(int, input().split()))
r = a[0]
g = a[1]
b = a[2]
n = a[3]
c = 0

for i in range(n+1):
    for j in range(n+1):
        k = (n - (r*i + g*j))//b
        if k >= 0:
            if n == r*i + g*j + b*k:
                c += 1
print(c)
### BUGGY CODE ###

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

L.sort()
L.reverse()

res = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        x = L[i] - L[j]
        for k in range(j+1, N):
            if L[k] <= x:
                break
            res += 1

print(res)

### FIXED CODE ###

import bisect

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

L.sort()

res = 0

for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        x = L[i] - L[j]
        idx = bisect.bisect_right(L, x)
        res += max(j-idx, 0)

print(res)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

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

def dfs(seq):
    if len(seq) == N:
        score = 0
        for i in range(N):
            if seq[i] == "1":
                score += s[i]
        if score % 10 == 0:
            return 0
        else:
            return score

    else:
        return max(dfs(seq + "0"), dfs(seq + "1"))

print(dfs(""))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N = int(input())
s = [int(input()) for i in range(N)]
wa = sum(s)
s.sort()
if wa % 10 != 0:
    print(wa)
else:
    for i in range(N):
        if s[i] % 10 != 0:
            print(wa - s[i])
            break
    else:
        print(0)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
x = 1

for i in range(n):
    x = x*a[i]
    
if x > 10**18:
    print('-1')

else:
    print(x)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
x = 1

a = sorted(a)

if a[0]==0:
    print(0)

else:
    for i in range(n):
        x = x*a[i]
    
        if x > 10**18:
            print('-1')
            break
        if i == n-1:
            print(x)
            break
### BUGGY CODE ###

x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
delist = []
for a in alist :
    for b in blist :
        for c in clist :
            delist.append(a+b+c)
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)

### FIXED CODE ###

x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort(reverse=True)
clist.sort(reverse=True)
delist = []
for a in range(x) :
    for b in range(y) :
        if a*b > k :
            break
        for c in range(z) :
            if a*b*c > k :
                break
            else :
                delist.append(alist[a]+blist[b]+clist[c])
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)
### BUGGY CODE ###

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c = [[[-1]*2 for i in range(w)] for i in range(h)]

def count(x,y):

    if c[x][y][0] == -1:
        n = 0
        while x+n < h and l[x+n][y] == ".":
            n += 1
        for i in range(n):
            c[x+i][y][0] = n
        
    if c[x][y][1] == -1:
        n = 0
        while y+n < w and l[x][y+n] == ".":
            n += 1
        for i in range(n):
            c[x][y+i][1] = n

    return c[x][y][0]+c[x][y][1]
ans = 0
for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            ans = max(ans,count(i,j))
print(ans-1)

### FIXED CODE ###


h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)