class SegmentTree: def segfunc(self,x,y): return min(x,y) def __init__(self,first_list,first_value): n = len(first_list) self.first_value = first_value self.num = 1<<(n-1).bit_length() self.tree = [first_value]*2*self.num for i in range(n): self.tree[self.num+i] = first_list[i] for i in range(self.num-1,0,-1): self.tree[i] = self.segfunc(self.tree[2*i],self.tree[2*i+1]) def update(self,k,x): k += self.num self.tree[k] = x while k>1: self.tree[k>>1] = self.segfunc(self.tree[k],self.tree[k^1]) k >>= 1 def query(self,l,r): res = self.first_value l += self.num; r += self.num while l>= 1; r >>= 1 return res def get(self, k): return self.tree[k+self.num] from bisect import bisect h,w = map(int,input().split()) s = [input() for _ in range(h)] t = [[-1]+[j for j in range(w) if s[i][j]=="#"]+[w] for i in range(h)] dp = SegmentTree([0]*w,w) for i in range(h-2,-1,-1): eq = [w]*w for j in range(w): if s[i][j]=="#": continue k = bisect(t[i],j); l = t[i][k-1]+1; r = t[i][k]-1 wa = -1; ac = w-1 while ac-wa>1: wj = (wa+ac)//2 if dp.query(max(j-wj,l),min(j+wj,r)+1)<=wj: ac = wj else: wa = wj eq[j] = ac dp = SegmentTree(eq,w) for i in range(w): print(dp.get(i))