//vodopad
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, h, levo, desno, j;
    cin >> h >> n;
    vector <vector <int> > x(h);
    for (int i = 0; i < h; i++)
    {
        x[i].resize(n);
        for (j = 0; j < n; j++) cin >> x[i][j];
    }
    vector <int> pre(n);
    vector <int> sad(n);
    for (int i = 0; i < n; i++) sad[i] = 1;
    for (int i = 0; i < h; i++)
    {
        pre = sad;
        sad = x[i];
        for (j = 0; sad[j] == 0; j++)
            pre[j+1] += pre[j];
        levo = j;
        for (j = n - 1; sad[j] == 0; j--)
            pre[j-1] += pre[j];
        desno = j;
        for (int k = levo; k <= desno; k++)
        {
            if (sad[k] == 1) sad[k] = pre[k];
            else
            {
                int kr, blpr = 0;
                for (kr = k; sad[kr] == 0; kr++) blpr += pre[kr];
                sad[k-1] += blpr/2;
                if (blpr % 2 != 0 && (i+1) % 2 == 1) sad[k-1]++;
                pre[kr] += blpr/2;
                if (blpr % 2 != 0 && (i+1) % 2 == 0) pre[kr]++;
                k = kr - 1;
            }
        }
    }
    for (int i = 0; i < n; i++) cout << sad[i] << " ";
    return 0;
}