#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);}) #define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) #define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);}) #define rep(v,e) for(typeof(e) v=0;v=b?a:b) #define chmin(v,a) (v=v<=a?v:a) char wbuf[1<<25]; int a[100000]; int b[100000]; int q[100000]; int f1(){ rd_init(); int h=rd(); int w=rd(); rp+=(w+1)*(h-1); rrep(y,h-1){ rp-=w+1; int qr=0,qw=-1; rep(x,w){ if(*rp++=='#'){ qr=0,qw=-1; b[x]=w; }else{ while(qr<=qw&&a[q[qw]]>=a[x]){ --qw; } q[++qw]=x; while(qr=a[q[qr+1]]){ ++qr; } b[x]=max(x-q[qr],a[q[qr]]); } } qr=0,qw=-1; rrep(x,w){ if(*--rp=='#'){ qr=0,qw=-1; }else{ while(qr<=qw&&a[q[qw]]>=a[x]){ --qw; } q[++qw]=x; while(qr=a[q[qr+1]]){ ++qr; } int t=max(q[qr]-x,a[q[qr]]); chmin(b[x],t); } } rep(x,w){ a[x]=b[x]; } } return w; } void f2(int w){ char*wp=wbuf+sizeof wbuf; rrep(x,w){ *--wp='\n'; wt(a[x]); } write(1,wp,wbuf+sizeof wbuf-wp); } int main(){ f2(f1()); _exit(0); }