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 dx = [0,0,1,-1] dy = [1,-1,0,0] 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 i in range(4): nx, ny = x+dx[i], y+dy[i] if not (0<= nx < h-2 and 0<=ny