#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <utility>
#include <iomanip>
#include <assert.h>
#include <complex>
#define MP make_pair
#define PB push_back
#define int long long
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#ifdef LOCAL
#define debug(x) {cerr <<#x <<" = " <<x <<"\n"; }
#define debug2(x, y) {cerr <<#x <<" = " <<x <<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z) {cerr <<#x <<" = " <<x <<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
using std::cerr;
#else
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define debugv(x)
#define cerr if(0)cout
#endif
#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;
using std::endl;
using std::cout;
using std::cin;
using std::vector;
using std::set;
using std::map;
using std::pair;
using std::max;
using std::min;
using std::ostream;
using std::fixed;
using std::ios_base;
using std::setprecision;
using std::make_pair;
using std::string;
using std::multiset;
using std::next_permutation;
using std::prev_permutation;
using std::random_shuffle;
using std::greater;
using std::lower_bound;
using std::upper_bound;
using std::reverse;
using std::swap;
using std::complex;
using std::sort;
typedef long long ll;
typedef long double LD;
//typedef pair<int, int> PII;
typedef pair<ll, ll> PII;
typedef pair<ll, ll> PLL;
typedef vector<ll> VI;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
const int N = 2e3;
int rec[N][N];
int b[N][N];
int dep[N][N];
#undef int
int main() {
#define int long long
//ios_base::sync_with_stdio(0);
cout << fixed << setprecision(10);
double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
make2(int, n, m);
RE (i, n) {
RE (j, m) {
char c;
scanf(" %c", &c);
b[i][j] = c - '0';
if (b[i][j] == 0) {
dep[i][j] = 0;
} else {
dep[i][j] = 1 + dep[i - 1][j];
}
}
}
RE (i, n) {
VPII stack;
stack.PB(MP(0, 0));
RE (j, m + 1) {
int last_popped = j;
while (stack.back().second > dep[i][j]) {
rec[stack.back().second][j - stack.back().first]++;
rec[max(stack[stack.size() - 2].second, dep[i][j])][j - stack.back().first]--;
last_popped = stack.back().first;
stack.pop_back();
}
stack.PB(MP(last_popped, dep[i][j]));
}
}
for (int tr = 1; tr <= 2; tr++) {
RE (i, n) {
FORD (j, m, 1) {
rec[i][j] += rec[i][j + 1];
}
}
}
RE (j, m) {
FORD (i, n, 1) {
rec[i][j] += rec[i + 1][j];
}
}
RE (i, n) {
RE (j, m) {
cout<<rec[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxjdGltZT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDx1dGlsaXR5PgojaW5jbHVkZSA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TsKICBkb3VibGUgYmVnX2Nsb2NrID0gMS4wICogY2xvY2soKSAvIENMT0NLU19QRVJfU0VDOwogIG1ha2UyKGludCwgbiwgbSk7CiAgUkUgKGksIG4pIHsKICAgIFJFIChqLCBtKSB7CiAgICAgIGNoYXIgYzsKICAgICAgc2NhbmYoIiAlYyIsICZjKTsKICAgICAgYltpXVtqXSA9IGMgLSAnMCc7CiAgICAgIGlmIChiW2ldW2pdID09IDApIHsKICAgICAgICBkZXBbaV1bal0gPSAwOwogICAgICB9IGVsc2UgewogICAgICAgIGRlcFtpXVtqXSA9IDEgKyBkZXBbaSAtIDFdW2pdOwogICAgICB9CiAgICB9CiAgfQogIAogIFJFIChpLCBuKSB7CiAgICBWUElJIHN0YWNrOwogICAgc3RhY2suUEIoTVAoMCwgMCkpOwogICAgUkUgKGosIG0gKyAxKSB7CiAgICAgIGludCBsYXN0X3BvcHBlZCA9IGo7CiAgICAgIHdoaWxlIChzdGFjay5iYWNrKCkuc2Vjb25kID4gZGVwW2ldW2pdKSB7CiAgICAgICAgcmVjW3N0YWNrLmJhY2soKS5zZWNvbmRdW2ogLSBzdGFjay5iYWNrKCkuZmlyc3RdKys7CiAgICAgICAgcmVjW21heChzdGFja1tzdGFjay5zaXplKCkgLSAyXS5zZWNvbmQsIGRlcFtpXVtqXSldW2ogLSBzdGFjay5iYWNrKCkuZmlyc3RdLS07CiAgICAgICAgbGFzdF9wb3BwZWQgPSBzdGFjay5iYWNrKCkuZmlyc3Q7CiAgICAgICAgc3RhY2sucG9wX2JhY2soKTsKICAgICAgfQogICAgICBzdGFjay5QQihNUChsYXN0X3BvcHBlZCwgZGVwW2ldW2pdKSk7CiAgICB9CiAgfQogIAogIGZvciAoaW50IHRyID0gMTsgdHIgPD0gMjsgdHIrKykgewogICAgUkUgKGksIG4pIHsKICAgICAgRk9SRCAoaiwgbSwgMSkgewogICAgICAgIHJlY1tpXVtqXSArPSByZWNbaV1baiArIDFdOwogICAgICB9CiAgICB9CiAgfQogIFJFIChqLCBtKSB7CiAgICBGT1JEIChpLCBuLCAxKSB7CiAgICAgIHJlY1tpXVtqXSArPSByZWNbaSArIDFdW2pdOwogICAgfQogIH0KICBSRSAoaSwgbikgewogICAgUkUgKGosIG0pIHsKICAgICAgY291dDw8cmVjW2ldW2pdPDwiICI7CiAgICB9CiAgICBjb3V0PDwiXG4iOwogIH0KCiAgcmV0dXJuIDA7Cn0=