#include <stdio.h>
#include <vector>

using namespace std;

const long long N=1e6+10;

long long n,h,br=0;
vector <long long> a[N];
vector <long long> b[N];

int main()
{
    scanf("%lld%lld",&h,&n);
    for (long long i=0;i<h;i++)
        for (long long j=0;j<n;j++)
        {
            long long d;
            scanf("%lld",&d);
            a[i].push_back(d);
            b[i].push_back(0);
        }


    long long j=0;
    while (j<n)
    {
        b[0][j]+=a[0][j];
        if (a[0][j]==0)
        {
            br+=1;
            long long brojac=0;
            for (long long z=j+1;z<n;z++)
            {
                if (a[0][z])
                {
                    break;
                }
                brojac++;
                br+=1;
            }
            if ((j+brojac)==(n-1))
            {
                b[0][j-1]+=br;
            }
            else if (j==0) b[0][j+brojac+1]+=br;
            else
            {
                b[0][j+brojac+1]+=br/2;
                b[0][j-1]+=br/2+br%2;
            }
            j+=brojac;
            br=0;
        }
        j++;
    }
    j=0;
    long long s;
    for (long long i=1;i<h;i++)
    {
        while (j<n)
        {
            if (a[i][j]) b[i][j]+=b[i-1][j];
            else b[i][j]=0;
            long long trj=j;
            if (a[i][j]==0)
            {
                br+=b[i-1][j];
                long long brojac=0;
                for (long long z=j+1;z<n;z++)
                {
                    if (a[i][z])
                    {
                        break;
                    }
                    brojac++;
                    br+=b[i-1][z];
                }
                if (j+brojac==n-1)
                {
                    b[i][j-1]+=br;
                }
                else if (j==0)
                {
                    b[i][j+brojac+1]+=br;
                }
                else
                {
                    b[i][j+brojac+1]+=br/2;
                    b[i][j-1]+=br/2;
                    if ((i+1)%2) b[i][j-1]+=br%2;
                    else b[i][j+brojac+1]+=br%2;
                }
                j=j+brojac;
                br=0;
            }
            j++;
        }
        j=0;
    }
    for (long long j=0;j<n;j++)
    {
        printf("%lld ",b[h-1][j]);
    }
    return 0;
}