using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] niz = Console.ReadLine().Split();
            int h =int.Parse(niz[0]);
            int n = int.Parse(niz[1]);
            int[,] mat = new int[h+1, n];
            for (int i = 0; i < n; i++)
            {
                mat[0, i] = 1;
            }
            for (int i = 1; i < h+1; i++)
            {
                string[] a = Console.ReadLine().Split();
                for (int j = 0; j < n; j++)
                {
                    if (a[j] == "1") mat[i, j] = 0;
                    if (a[j] == "0") mat[i, j] = 5;
                }
            }            
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < n; j++)
                {                                        
                    if (mat[i + 1, j] != 5) mat[i + 1, j] += mat[i, j];
                    int pom = j;
                    int kvd = 0;
                    int kvl = 0;
                    int y1 = 0;
                    int y2 = 0;
                    if (mat[i + 1, j] == 5)
                    {                        
                        if ((i + 1) % 2 == 0)
                        {
                            kvd = mat[i, j] / 2 + mat[i, j] % 2;
                            kvl = mat[i, j] / 2;
                        }
                        if ((i + 1) % 2 == 1)
                        {
                            kvl = mat[i, j] / 2 + mat[i, j] % 2;
                            kvd = mat[i, j] / 2;    
                        }
                        while (mat[i + 1, pom] == 5)
                        {
                            pom -= 1;
                            if (pom < 0) { kvd += kvl; break; }
                            if (mat[i + 1, pom] != 5)
                            {
                                mat[i + 1, pom] += kvl;
                                y1 = i + 1;
                                y2 = pom;
                            }
                        }
                        
                        pom+=1;
                        while (mat[i + 1, pom] == 5)
                        {
                            pom += 1;
                            if (pom > n - 1) { mat[y1, y2] += kvd; break; }
                            if (mat[i + 1, pom] != 5)
                            {
                                mat[i + 1, pom] += kvd;
                            }
                        }                        
                    }
                }
                for (int z = 0; z < n; z++)
                {
                    if (mat[i+1, z] == 5) mat[i+1, z] = 0;
                }                 
                }
            for (int p = 0; p < n; p++)
            {
                Console.Write(mat[h, p]+" ");
            }
            Console.WriteLine();
            }           
        }
    }