import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd h,w = map(int,input().split()) s = [input().rstrip() for i in range(h)] g = [[0]*(w-2) for i in range(h-2)] for i in range(1,h-1): for j in range(1, w-1): ok = 1 for dx in [0,-1,1]: for dy in [0,-1,1]: ok &= s[i+dx][j+dy] == "." g[i-1][j-1] = ok def bfs(x,y,g): que = deque([(x,y)]) depth = [[-1]*(w-2) for i in range(h-2)] depth[x][y] = 0 while que: x,y = que.popleft() for dx in [1,0,-1]: for dy in [1,0,-1]: if dx == 0 and dy == 0: continue nx, ny = x+dx, y+dy if not (0<= nx < h-2 and 0<=ny