#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{

    long h;
    long n;
    long matrica[h][n];

    cin>>h>>n;

    long nizZadnjegReda[n];

    for(int i = 0;i<h;i++)
        for(int j = 0;j<n;j++)
        {
            cin>>matrica[i][j];
            nizZadnjegReda[j]=matrica[i][j];
        }
    //for(int i = 0;i<h;i++)
    //{
    //   for(int j = 0;j<n-1;j++)
    //        cout<<matricaVodopada[i][j]<<" ";
    //    cout<<matricaVodopada[i][n-1]<<"\n";
    //}

for (long j = 0; j < n; j++)
            {
                if (matrica[0][ j] == 0)
                {
                    long levo = -1;
                    for (long t = j - 1; t >= 0; t--)
                    {
                        if (matrica[j][ t] != 0) levo = t;
                    }

                    if (levo != -1)
                        matrica[0][ levo] += 1;
                    else
                    {
                        long desno = -1;
                        for (long c = j + 1; c < n; c++)
                        {
                            if (matrica[0][ c] != 0) desno = c;
                        }
                        matrica[0][desno] += 1;
                    }
                }
            }

            for (long i = 1; i < h - 1; i++)
            {
                for (long j = 0; j < n; j++)
                {
                    if(matrica[i][j]==0)
                    {
                        long desno = -1;
                        for (long c = j + 1; c < n; c++)
                        {
                            if (matrica[i][ c] != 0) desno = c;
                        }
                        long levo = -1;
                        for (long t = j - 1; t >= 0; t--)
                        {
                            if (matrica[i][ t] != 0) levo = t;
                        }

                        if (levo == -1)
                            matrica[i][ desno] += matrica[i - 1][ j];
                        else
                        if (desno == -1)
                            matrica[i][ levo] += matrica[i - 1][ j];
                        else
                        if(matrica[i-1][j]%2==0)
                        {
                            matrica[i][ levo] += matrica[i - 1][ j] / 2;
                            matrica[i][ desno] += matrica[i - 1][ j] / 2;
                        }
                        else
                        if((i+1)%2==0)
                        {
                            matrica[i][ levo] += (matrica[i - 1][ j] - 1) / 2 + 1;
                            matrica[i][ desno] += (matrica[i - 1][ j] - 1) / 2;
                        }
                        else {
                            matrica[i][ desno] += (matrica[i - 1][ j] - 1) / 2 + 1;
                            matrica[i][ levo] += (matrica[i - 1][ j] - 1) / 2;
                        }
                    }
                }
            }

    for(int i = 0; i < n-1; i++)
        cout<<matrica[h-1][i]<<" ";
    cout<<matrica[h-1][n-1];
    return 0;
}