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

from collections import deque
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
edge = [[] for _ in range(n)]
mat = [[1000] * n for _ in range(n)]
for i in range(n):
    s = input().rstrip()
    for j, ch in enumerate(s):
        if ch == "1":
            mat[i][j] = 1
            if j > i:
                edge[i].append(j)
                edge[j].append(i)
for i in range(n):
    mat[i][i] = 0
for k in range(n):
    for i in range(n):
        for j in range(n):
            mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j])

ans = 0
dq = deque()
dist = [-1] * n
dq.append((i, 0))
ok = True
while dq:
    v, d = dq.popleft()
    if dist[v] == -1:
        dist[v] = d
    elif dist[v] != d:
        ok = False
        break
    for item in edge[v]:
        if dist[item] == -1:
            dq.append((item, d+1))

if ok:
    ans = 0
    for line in mat:
        ans = max(ans, max(line))
    print(ans + 1)
else:
    print(-1)

### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
edge = [[] for _ in range(n)]
mat = [[1000] * n for _ in range(n)]
for i in range(n):
    s = input().rstrip()
    for j, ch in enumerate(s):
        if ch == "1":
            mat[i][j] = 1
            if j > i:
                edge[i].append(j)
                edge[j].append(i)
for i in range(n):
    mat[i][i] = 0
for k in range(n):
    for i in range(n):
        for j in range(n):
            mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j])

ans = 0
dq = deque()
dist = [-1] * n
dq.append((0, 0))
ok = True
while dq:
    v, d = dq.popleft()
    if dist[v] == d:
        continue
    if dist[v] == -1:
        dist[v] = d
    else:
        ok = False
        break
    for item in edge[v]:
        if dist[item] == -1:
            dq.append((item, d+1))

if ok:
    ans = 0
    for line in mat:
        ans = max(ans, max(line))
    print(ans + 1)
else:
    print(-1)
### BUGGY CODE ###

import math
a, b, c = map(int, input().split())
for i in range(1, 9):
  while (a % i == 0 and b % i == 0 and c % i == 0):
    if (a == i or b == i or c == i):
      break
    a /= i
    b /= i
    c /= i
left = a * b
right = (c - (a + b)) / 2
right = right ** 2
if (left < right):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

a, b, c = map(int, input().split())
left = 4 * a * b
right = c - (a + b)
if (right < 0):
  print('No')
  exit()
right = right ** 2
if (left < right):
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

s = input()
t = input()

sl = list(s)
sn = len(sl)

from itertools import permutations

sp = []
for v in permutations(sl, sn):
    sp.append("".join(list(v)))

tl = list(t)
tn = len(tl)
tp = []
for v in permutations(tl, tn):
    tp.append("".join(list(v)))

f = False
for se in sp:
    for te in tp:
        if se < te:
            f = True
            break
    if f:
        break

if f:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
t = input()

s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))

if s < t:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

import math
n=int(input())
s=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      s += math.gcd(i,math.gcd(j,k))
print(s)


### FIXED CODE ###

import math
  
def main():
  k=int(input())
  cur=0
  for a in range(1,k+1):
    for b in range(1,k+1):
      for c in range(1,k+1):
        cur+=math.gcd(math.gcd(a,b),c)
        
  return cur
print(main())
### BUGGY CODE ###

def main():
    N,K = map(int,input().split())
    A = [0]
    A += list(map(int,input().split()))

    i = 1
    pas = [0]*N
    pas[0] = 1
    k = 1
    while k <= K:
        if A[i] in pas:
            rps = pas.index(A[i]) # roop start index
            ans = A[i]
            break
        pas[k] = A[i]
        ans = A[i]
        i = A[i]
        k += 1

    if k >= K:
        print(ans)
    else:
        rpnum = (K-rps)%(k-rps)
        print(pas[rps+rpnum])

main()

### FIXED CODE ###

import numpy as np

def main():
    N,K = map(int,input().split())
    A = [0]
    A += list(map(int,input().split()))
    A = np.array(A)
    
    i = 1
    pas = np.zeros(N)
    pas[0] = i
    k = 1
    pass_set = set(pas)
    while k <= K:
        if A[i] in pass_set:
            rps = np.where(pas==(A[i]))[0]
            ans = A[i]
            break
        pas[k] = A[i]
        pass_set.add(A[i])
        ans = A[i]
        i = A[i]
        k += 1

    if k >= K:
        print(ans)
    else:
        rpnum = (K-rps[0])%(k-rps)
        print(int(pas[rps[0]+rpnum]))

main()
### BUGGY CODE ###

import bisect
K, S = map(int,input().split())
listK = [i for i in range(K+1)]
list2K = [i for i in range(K**2)]
ans = 0
for i in range(K+1):
    id = bisect.bisect_left(list2K,S-i)
    if id < len(list2K) and list2K[id] == S-i:
        for j in range(K+1):
            id2 = bisect.bisect_left(listK,list2K[id]-j)
            if id2 < len(listK) and listK[id2] == list2K[id]-j:
                ans += 1
print(ans)

### FIXED CODE ###

K, S = map(int,input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z and z <= K:
            ans += 1
print(ans)
### BUGGY CODE ###

import queue
import sys 
input=sys.stdin.readline

def main():
    n,m,k=map(int,input().split())
    root={}
    ng={}

    for i in range(n):
        root[i]=[]
        ng[i]=[]
    for i in range(m):
        a,b=map(int,input().split())
        root[a-1].append(b-1)
        root[b-1].append(a-1)
     #   ng[a-1].append(b-1)
      #  ng[b-1].append(a-1)
    for i in range(k):
        a,b=map(int,input().split())
        ng[a-1].append(b-1)
        ng[b-1].append(a-1)
    
    Vstd=[]
    v_append=Vstd.append
    checkVst=[False]*n
    num=[0]*n
    ToVst=queue.Queue()
    for i in range(n):
        if checkVst[i]:
            continue
        Vstd=[]
        v_append=Vstd.append
        now=i
        v_append(now)
        checkVst[now]=True

        for kouho in root[now]:
            if checkVst[kouho]:
                continue
            ToVst.put(kouho)
            checkVst[kouho]=True

        while ToVst.empty()==False:
            now=ToVst.get()
            v_append(now)
            checkVst[now]=True
           
            for kouho in root[now]:
                if checkVst[kouho]:
                    continue
                ToVst.put(kouho)
                checkVst[kouho]=True
                
        lengh=len(Vstd)
        for v in Vstd:
            num[v]=lengh-1
            num[v]-=len((set(ng[v]) | set(root[v]))&set(Vstd))
    print(*num)
    #print(" ".join(map(str,num)))
   

if __name__=="__main__":
    main()
    
        

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m,k=map(int,input().split())
uf=UnionFind(n)
block={}
for i in range(n):
    block[i]=[i]
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    block[a-1].append(b-1)
    block[b-1].append(a-1)
    
for i in range(k):
    a,b=map(int,input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
ans=[]
#print(block)
for i in range(n):
    res=uf.size(i)
 #   print(res)
    for value in block[i]:
        if uf.same(value,i):
            res-=1
    ans.append(res)
print(*ans)
### BUGGY CODE ###


import numpy as np
N,M=map(int, input().split())
key=[]
for i in range(M):
    a,b=map(int, input().split())
    C=list(map(int, input().split()))
    c=0
    for d in C:
        c+=2**(d-1)
    key.append((a,b,c))

dp=np.ones((2**N))*np.inf
dp[0]=0
for bi in range(0,2**N):
    for i in range(M):
        t=key[i]
        a,b,c=t
        

        dp[bi|c]=min(dp[bi]+a,dp[bi|c])
if dp[-1]!=np.inf:
    print(int(dp[-1]))
else:
    print(-1)
    

### FIXED CODE ###

n,m = map(int,input().split())
dp = [0]+[10**8+10]*(2**n-1)
for i in range(m):
  a,b = map(int,input().split())
  s = sum([2**(x-1) for x in list(map(int,input().split()))])
  for j in range(2**n):
    dp[j|s] = min(dp[j|s],dp[j]+a)
if dp[-1] <= 10**8:
  print(dp[-1])
else:
  print(-1)
### BUGGY CODE ###

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

ans=1
flag0=0
flag1=0
inf=1000000000000000000

for a in A:
	ans=ans*a
	if(a==0):
		flag0=1
	if(ans>inf):
		flag1=1
	
if flag0==1:
	print(0)
elif flag1==1:
	print(-1)
else:
	print(ans)

### FIXED CODE ###

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

ans=1
flag0=0
flag1=0
inf=1000000000000000000

for a in A:
	if(a==0):
		flag0=1
		
if flag0==1:
	print(0)
	
else:
	for a in A:
		ans=ans*a
		if(ans>inf):
			flag1=1
			break

	if flag1==1:
		print(-1)
	else:
		print(ans)
### BUGGY CODE ###

def Qb():
    n = int(input())
    lina = map(int, input().split())

    ans = 1
    for i, a in enumerate(lina):
        ans *= a
    if 10 ** 18 < ans:
        ans = -1
    print(ans)


if __name__ == '__main__':
    Qb()


### FIXED CODE ###

def Qb():
    n = int(input())
    lina = list(map(int, input().split()))

    if 0 in lina:
        print(0)
        exit()

    ans = 1
    for a in lina:
        ans *= a
        if 10 ** 18 < ans:
            ans = -1
            break
    print(ans)

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

#120 C
S =input()
min_=min(S.count('0'),S.count('1'))
cnt=0
for i in range(min_):
    if S.count('01')>0:
        S=S.replace('01','',1)
        cnt+=2
    if  S.count('10')>0:
        S=S.replace('10','',1)
        cnt+=2
print(cnt)

### FIXED CODE ###

#120 C
S =input()
print(min(S.count('0'),S.count('1'))*2)
### BUGGY CODE ###

def W_tips(j):
    global K,g,now,tips
    for i in range(g):
        now[i]+=tips[i][j]
    for i in range(g):
        if now[i] > K:
            return False
    return True

f_inf=float("inf")
H,W,K=map(int,input().split())
s=[None]*H
for i in range(H):
    s[i]=str(input())
ans = f_inf
for div in range(1 << (H-1)):
    g=int(0)
    id =[0]*H
    for j in range(H):
        id[j]=g
        if div>>j&1:g+=1
    num = g
    g+=1
    tips=[[0 for i in range(W)] for j in range(g)]
    for i in range(H):
        for j in range(W):
            tips[id[i]][j]+=(s[i][j] !="0")
    now=[0]*g
    for j in range(W):
        if W_tips(j)==False:
            num+=1
            now=[0]*g
            if W_tips(j)==False:
                num=f_inf
                break
    ans=min(ans,num)
print(ans)


### FIXED CODE ###

def W_tips(j):
    global K,g,now,tips
    for i in range(g):
        now[i]+=tips[i][j]
    for i in range(g):
        if now[i] > K:
            return False
    return True

f_inf=float("inf")
H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for _ in range(H)]
ans = f_inf
for div in range(1 << (H-1)):
    g=0
    tips=[[0]*W]
    tips[g]=[s+b for s, b in zip(S[0],tips[g])]
    for i in range(1,H):
        if div >> (i-1) &1:
            g+=1
            tips.append([0]*W)
        tips[g]=[s + b for s, b in zip(S[i],tips[g])]
    num=g
    g+=1
    now=[0]*g
    for j in range(W):
        if W_tips(j)==False:
            num+=1
            now=[0]*g
            if W_tips(j)==False:
                num=f_inf
                break
    ans=min(ans,num)
print(ans)
### BUGGY CODE ###

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

def segfunc(x,y):
    return (len(x[1]|y[1]),x[1]|y[1])

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = [0,set()]

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

A = []
for i in range(n):
  A.append((1,set(s[i])))
init(A)
q = int(input())
for _ in range(q):
  p,a,b = input().split()
  if p == "1":
    update(int(a)-1,(1,set(b)))
  if p == "2":
    print(query(int(a)-1,int(b))[0])
    

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  n = int(input())
  s = list(input())

  def segfunc(x,y):
      return x|y

  def init(init_val):
      #set_val
      for i in range(n):
          seg[i+num-1]=init_val[i]    
      #built
      for i in range(num-2,-1,-1) :
          seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
      
  def update(k,x):
      k += num-1
      seg[k] = x
      while k:
          k = (k-1)//2
          seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
      
  def query(p,q):
      if q<=p:
          return ide_ele
      p += num-1
      q += num-2
      res=ide_ele
      while q-p>1:
          if p&1 == 0:
              res = segfunc(res,seg[p])
          if q&1 == 1:
              res = segfunc(res,seg[q])
              q -= 1
          p = p//2
          q = (q-1)//2
      if p == q:
          res = segfunc(res,seg[p])
      else:
          res = segfunc(segfunc(res,seg[p]),seg[q])
      return res

  #####単位元######
  ide_ele = 0

  #num:n以上の最小の2のべき乗
  num =2**(n-1).bit_length()
  seg=[ide_ele]*2*num

  A = []
  for i in range(n):
    A.append(1<<(ord(s[i])-96))
  init(A)
  q = int(input())
  for _ in range(q):
    p,a,b = input().split()
    if p == "1":
      update(int(a)-1,1<<(ord(b)-96))
    if p == "2":
      print(bin(query(int(a)-1,int(b))).count("1"))
main()
### BUGGY CODE ###

s=str(input())
q=int(input())
now = 0
mae,usiro="",""
for _ in range(q):
  lis = list(map(str,input().split()))
  if int(lis[0]) == 1:
    now = (now+1)%2
  else:
    if (int(lis[1])+now)%2 == 1:
      mae = lis[2]+mae
    else:
      usiro= usiro +lis[2]
s = mae+s+usiro
if now ==0:
  print(s)
else:
  print(s[::-1])
    
  


### FIXED CODE ###

s=str(input())
q=int(input())
now = 0
mae,usiro="",""
for _ in range(q):
  lis = list(map(str,input().split()))
  if int(lis[0]) == 1:
    now = (now+1)%2
  else:
    if (int(lis[1])+now)%2 == 1:
      mae = lis[2]+mae
    else:
      usiro= usiro +lis[2]
s = mae+s+usiro
if now ==0:
  print(s)
else:
  print(s[::-1])
### BUGGY CODE ###

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

A_sum = sum(A)
ans = 0

for i in range(N-1):
    B = A.pop(0)
    A_sum -= B
    ans += A_sum*B
print(ans % (10**9+7))


### FIXED CODE ###

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

A_sum = sum(A)
ans = 0


for i in range(N-1):
    A_sum -= A[i]
    ans += A_sum*(A[i])

print(ans%(10**9+7))
### BUGGY CODE ###

k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  myconst = 7
  cnt = 1
  while True:
    if myconst % k == 0:
      print(cnt)
      break
    else:
      myconst = (10 * myconst) + 7
    cnt += 1
 
      


### FIXED CODE ###

k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  myconst = 7 % k
  cnt = 1
  while True:
    if not myconst:
      print(cnt)
      break
    else:
      myconst = ((10 * myconst) + 7) % k
    cnt += 1
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
a.sort()
pin=0


lst=[1,1]
for i in range(2,n+10):
  lst.append((lst[-1]*i)%mod)

def combinations(n,r):
  xxx=lst[n]
  xxx*=pow(lst[n-r],mod-2,mod)
  xxx%=mod
  xxx*=pow(lst[r],mod-2,mod)
  xxx%=mod

  return xxx


for i in range(n-k+1):
  pin+=1
  now=n-k+1-i
  ans+=(sum(a[-now:])-sum(a[:now]))*combinations(pin+k-3,k-2)
  ans%=mod


print(ans)

### FIXED CODE ###

import itertools

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
a.sort()
a=list(itertools.accumulate(a))
pin=0


lst=[1,1]
for i in range(2,n+10):
  lst.append((lst[-1]*i)%mod)

def combinations(n,r):
  xxx=lst[n]
  xxx*=pow(lst[n-r],mod-2,mod)
  xxx%=mod
  xxx*=pow(lst[r],mod-2,mod)
  xxx%=mod

  return xxx

if k==1:
    print(0)
    exit()


for i in range(n-k+1):
  pin+=1
  now=n-k+1-i
  ans+=(a[-1]-a[-now-1]-a[now-1])*combinations(pin+k-3,k-2)
  ans%=mod


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

N=int(input())
G=[[] for n in range(N)]
E=[]
for n in range(N-1):
    a,b=map(int,input().split())
    E.append((a-1,b-1))
    G[a-1].append(b-1)
    G[b-1].append(a-1)
deg=[len(v) for v in G]
K=max(deg)
Q=[0]
X=[]
color_map={}
while Q!=[]:
    v=Q.pop(0)
    X.append(v)
    for u in G[v]:
        if u not in X:
            Q.append(u)
    if v!=0:
        p=(set(X)&set(G[v])).pop()
        colors=set(range(1,K+1))
        for edge in color_map.keys():
            if p in edge:
                colors-={color_map[edge]}
        a,b=min(p,v),max(p,v)
        color_map[(a,b)]=colors.pop()
print(K)
for edge in E:
    print(color_map[edge])


### FIXED CODE ###

from collections import deque

N=int(input())
G=[[] for n in range(N)]
E=[]
for n in range(N-1):
    a,b=map(int,input().split())
    E.append((a-1,b-1))
    G[a-1].append(b-1)
    G[b-1].append(a-1)
K=max([len(v) for v in G])

P=[-1]*N
Q=[0]
X=[]
count=0
while Q:
    v=Q.pop()
    X.append(v)
    for u in G[v]:
        if u==P[v]:
            continue
        P[u]=v
        Q.append(u)

C={}
for v in X:
    color=0
    try:
        p_color=C[tuple(sorted((v,P[v])))]
    except:
        p_color=-1
    for u in G[v]:
        if u==P[v]:
            continue
        if color==p_color:
            color+=1
        C[tuple(sorted((u,v)))]=color
        color+=1

print(K)
for e in E:
    print(C[e]+1)
### BUGGY CODE ###



N = int(input())
A=[]
for i in range(N):
    A.append(input())
    
 
def verify_anagrams(w1, w2):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(w1) == f(w2)
  
ans=0
for i in range(N):
    for j in range(i+1,N):
#         print(i,j)
#         print(verify_anagrams(A[i],A[j]))
        if verify_anagrams(A[i],A[j]):
            ans+=1
print(ans)

### FIXED CODE ###

N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)
### BUGGY CODE ###

# 整数の入力
N = int(input())

# スペース区切りの整数の入力
datas = list(map(int, input().split()))

# non_conflict = list(set(datas))
# conf_num = len(datas) - len(non_conflict)

# blocks = sorted(datas)
blocks = list(datas)

cnt = 0
i = 1
while i <= len(blocks):
    if blocks[i-1] != i:
        cnt += 1
        blocks.pop(i-1)
        continue
    i += 1



# 出力
if cnt == len(datas):
    print(-1)
else:
    print(cnt)


### FIXED CODE ###

# 整数の入力
N = int(input())

# スペース区切りの整数の入力
datas = list(map(int, input().split()))

idx = 1
for i in range(len(datas)):	
    if datas[i] == idx:
        idx += 1


# ans = len(datas) - (idx-1)
if idx - 1 == 0:
    print(-1)
else:
    print(len(datas) - (idx-1))
### BUGGY CODE ###

ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

h,w  = na()
grid = [input().strip() for i in range(h)]
#print(grid)

T = [[0]*w for i in range(h)]
Y = [[0]*w for i in range(h)]

for i in range(h):
    count=0
    for j in range(w):
        if(grid[i][j]=="#"):
            count=0
        else:
            count+=1
            #print(i,j)
            T[i][j]=count

for i in range(h):
    for j in range(w-2,-1,-1):
        if grid[i][j] == "#":
            T[i][j] = 0
        else:
            T[i][j] = max(T[i][j],T[i][j+1])

for j in range(w):
    count=0
    for i in range(h):
        if(grid[i][j]=="#"):
            count=0
        else:
            count+=1
            Y[i][j]=count

for j in range(w):
    for i in range(h-2,-1,-1):
        if grid[i][j] == "#":
            Y[i][j] = 0
        else:
            Y[i][j] = max(Y[i][j],Y[i+1][j])

ANS = -1
for i in range(h):
    for j in range(w):
        ANS = max(ANS, Y[i][j] + T[i][j] - 1)
#print(T)
#print(Y)
print(ANS)

### FIXED CODE ###

ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

h,w  = na()
grid = [input().strip() for i in range(h)]
#print(grid)

T = [[0]*w for i in range(h)]
Y = [[0]*w for i in range(h)]

for i in range(h):
    count=0
    for j in range(w):
        if(grid[i][j]=="#"):
            count=0
        else:
            count+=1
            #print(i,j)
            T[i][j]=count

for i in range(h):
    for j in range(w-2,-1,-1):
        if grid[i][j] == "#":
            T[i][j] = 0
        else:
            T[i][j] = max(T[i][j],T[i][j+1])

for j in range(w):
    count=0
    for i in range(h):
        if(grid[i][j]=="#"):
            count=0
        else:
            count+=1
            Y[i][j]=count

for j in range(w):
    for i in range(h-2,-1,-1):
        if grid[i][j] == "#":
            Y[i][j] = 0
        else:
            Y[i][j] = max(Y[i][j],Y[i+1][j])

ANS = -1
for i in range(h):
    for j in range(w):
        ANS = max(ANS, Y[i][j] + T[i][j] - 1)
#print(T)
#print(Y)
print(ANS)
### BUGGY CODE ###

nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
h = list(map(int, input().split()))
observatories = list(range(1, n + 1))
for i in range(m):
  ab = list(map(int, input().split()))
  a = ab[0]
  b = ab[1]
  if h[a - 1] >= h[b - 1]:
    if b in observatories:
      observatories.remove(b)
  if h[a - 1] <= h[b - 1]:
    if a in observatories:
      observatories.remove(a)
print(len(observatories))

### FIXED CODE ###

nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
h = list(map(int, input().split()))
observatories = [[] for i in range(n)]
ans = 0
for i in range(m):
  ab = list(map(int, input().split()))
  a = ab[0] - 1
  b = ab[1] - 1
  observatories[a].append(b)
  observatories[b].append(a)
for j in range(len(observatories)):
  ans = ans + 1
  h_j = h[j]
  for k in observatories[j]:
    if h[k] >= h_j:
      ans = ans - 1
      break
print(ans)