#include #include using ll = long long; using ull = unsigned long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++) using namespace std; using namespace atcoder; using mint = modint998244353; const int inf = 1000000007; const ll longinf = 1ll << 60; int op(int x, int y) { return min(x, y); } int e() { return inf; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int h, w; cin >> h >> w; vector s(h); rep(i, h) cin >> s[i]; vector dp(w, 0); for(int i = h - 2; i >= 0; i--) { vector ndp(w, inf); atcoder::segtree sg(dp); int l = 0, r = 0; rep(j, w) { if(s[i][j] == '#') { l = j + 1; r = j + 1; continue; } while(r < w && s[i][r] == '.') ++r; int ok = w, ng = -1; while(ok - ng > 1) { int mid = (ok + ng) / 2; int val = sg.prod(max(l, j - mid), min(r, j + mid + 1)); if(val <= mid) { ok = mid; } else { ng = mid; } } ndp[j] = ok; } dp.swap(ndp); } rep(i, w) cout << dp[i] << "\n"; return 0; }