program turbopascal;
var
  voda:array[0..100] of integer;
  stena:array[0..100] of integer;
  h,n,i,v,j,zb,zap,x:integer;

{$mode objfpc}{$H+}
 begin
      read(h,n);
      for i:=1 to n do
          begin
            voda[i]:=1
          end;
      voda[n+1]:=-1;
      voda[0]:=-1;
      zb:=0;
      for v:=1 to h do
          begin
            if voda[zap+zb+1]<>-1 then zb:=0;
            zap:=1;
          for j:=1 to n do
              begin
              read(stena[j]);
              if (stena[j]=0) then
              begin
                   zb:=zb+1;
                   voda[j]:=0;
              end else
              if (v mod 2 = 0 ) then
                 begin
                     if voda[zap+zb+1]=-1 then
                        begin
                            voda[zap]:=voda[zap]+zb;
                            zap:=j;
                        end else if stena[j-zb-1]=0 then
                               begin
                                   voda[j]:=voda[j]+zb;
                                   zap:=j;
                               end else
                                   begin
                                      if zb div 2 =1 then
                                            begin
                                              voda[j]:=voda[j]+1;
                                              zb:=zb-1
                                            end;
                                      if zb div 2 = 0 then
                                            begin
                                               voda[j]:=voda[j]+zb div 2;
                                               voda[zap]:=voda[zap]+zb div 2;
                                            end;
                                      zap:=j;
                                   end;

                 end else
                     begin
                         if voda[j-zb-1]=-1 then
                        begin
                            voda[j]:=voda[j]+zb;
                            zap:=j;
                        end else if stena[zap+zb+1]=0 then
                               begin
                                   voda[zap]:=voda[zap]+zb;
                                   zap:=j;
                               end else
                                   begin
                                      if zb div 2 =1 then
                                            begin
                                              voda[j]:=voda[j]+1;
                                              zb:=zb-1
                                            end;
                                      if zb div 2 = 0 then
                                            begin
                                               voda[j]:=voda[j]+zb div 2;
                                               voda[zap]:=voda[zap]+zb div 2;
                                               zb:=0;

                                            end;
                                      zap:=j;
                                   end;
                     end;

              end;
          end;
      for x:=1 to n do write(voda[i],' ')  ;
      read(i);
   end.