program da;
var a:array [0..10000,1..10000] of integer;
    b:array [1..100] of integer;
    v,k,h,n,levi,desni,r:integer;
begin
read(h,n);
for v:=1 to h do
    for k:=1 to n do
        read(a[v,k]);
for k:=1 to n do
    a[0,k]:=1;
    
for v:=0 to h-1 do
    begin
    for r:=1 to n do
        b[r]:=0;
    
    for k:=1 to n do
        begin
        if a[v,k]<>0 then
            begin
            if a[v+1,k]=1 then b[k]:=b[k]+a[v,k]
            else
                begin
                levi:=0;
                desni:=0;
                for r:=1 to k do
                    if a[v+1,r]=1 then levi:=r;
                for r:=n downto k do
                    if a[v+1,r]=1 then desni:=r;
                
                if levi*desni<>0 then
                    begin
                    b[levi]:=b[levi]+(a[v,k] div 2);
                    b[desni]:=b[desni]+(a[v,k] div 2);
                    if a[v,k] mod 2=1 then
                        begin
                        if (v+1) mod 2=1 then
                            b[levi]:=b[levi]+1
                        else
                            b[desni]:=b[desni]+1;
                        end;
                    
                    end
                    else
                        if levi=0 then b[desni]:=b[desni]+a[v,k]
                             else b[levi]:=b[levi]+a[v,k];
                
                end;
            end;
        end;
        for r:=1 to n do
                    a[v+1,r]:=b[r];
    end;
for k:=1 to n do
    begin
    write(a[h,k]);
    write(' ');
    end;
end.