#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long h, n, br, brl, brd;
    bool d = false, l = false, prvi = false;
    cin >> h >> n;
    long long mat[h][n];
    for(int i = 0 ; i <= h ; i++){
        for(int j = 0 ; j < n ; j++){
            if(i != 0) cin >> mat[i][j];
            else mat[i][j] = 1;
            mat[i][j]--;
        }
    }
    for(int i = 0 ; i < h ; i++){
        for(int j = 0 ; j < n ; j++){
                if(mat[i][j] != -1 && mat[i + 1][j] == -1){
                    if(j == 0 || j == n - 1){
                        br = j;
                        d = false;
                        l = false;
                        if(j == 0) d = true;
                        else l = true;
                        if(d == true){
                        while(mat[i + 1][br] == -1){
                            br++;
                        }
                        }
                        else{
                        while(mat[i + 1][br] == -1){
                            br--;
                        }
                        }
                        if(mat[i][j] == 0) mat[i][j]++;
                        mat[i + 1][br] += mat[i][j];
                    }
                    else{
                        brd = brl = j;
                        while(mat[i + 1][brd] == -1){
                            brd++;
                        }
                        while(mat[i + 1][brl] == -1){
                            brl--;
                        }
                        if(mat[i][j] % 2 == 0){
                            mat[i + 1][brd] += mat[i][j] / 2;
                            mat[i + 1][brl] += mat[i][j] / 2;
                        }
                        else if((j + 1) % 2 == 0){
                        mat[i + 1][brd] += mat[i][j] / 2 + 1;
                        mat[i + 1][brl] += mat[i][j] / 2;
                        }
                        else{
                        mat[i + 1][brd] += mat[i][j] / 2 + 1;
                        mat[i + 1][brl] += mat[i][j] / 2;
                        }
                    }
                }
                else if(mat[i][j] != -1 && mat[i + 1][j] != -1){
                    mat[i + 1][j] += 1;
                }
        }
    }
    for(int i = 0 ; i < n ; i++){
            if(mat[h][i] != -1) cout << mat[h][i] << " ";
            else cout << 0 << " ";

    }

    return 0;
}