#include <bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

int h,n;

vector<int> NextState(vector<int>& prevState,vector<pii>& Slivovi,int idx){
    vector<int> nextState(n,0);
    for(int i=0;i<n;++i){
        nextState[Slivovi[i].f]+=prevState[i]/2;
        nextState[Slivovi[i].s]+=prevState[i]/2;
        if(idx%2){
            nextState[Slivovi[i].s]+=(prevState[i]%2);
        }else{
           nextState[Slivovi[i].f]+=(prevState[i]%2);
        }
    }
    return nextState;
}

void BuildSlivovi(vector<vector<pii>>& slivovi,vector<vector<int>>& sums,vector<vector<int>>& mat){
  for(int i=0;i<h;++i){
    for(int j=0;j<n;++j){
        if(mat[i][j]){slivovi[i][j]=make_pair(j,j);continue;}
        if(j==0){
            int idx=distance(sums[i].begin(),lower_bound(sums[i].begin(),sums[i].end(),sums[i][j]+1));
            slivovi[i][j]=make_pair(idx,idx);
            continue;
        }
        if(j==n-1){
             int idx=distance(sums[i].begin(),upper_bound(sums[i].begin(),sums[i].end(),sums[i][j]-1));
            slivovi[i][j]=make_pair(idx,idx);
            continue;
        }
        int idx1,idx2;
        idx1=distance(sums[i].begin(),upper_bound(sums[i].begin(),sums[i].end(),sums[i][j]-1));
        idx2=distance(sums[i].begin(),lower_bound(sums[i].begin(),sums[i].end(),sums[i][j]+1));
        slivovi[i][j]=make_pair(idx1,idx2);
    }
  }
}

void Print(vector<vector<int>>& mat){
  for(int i=0;i<h;++i){
    for(int j=0;j<n;++j){
        cout << mat[i][j] << " ";
    }
    cout << endl;
  }
}

void Print(vector<vector<pii>>& mat){
  for(int i=0;i<h;++i){
    for(int j=0;j<n;++j){
        cout << "(" << mat[i][j].f << " " << mat[i][j].s << ") ";
    }
    cout << endl;
  }
}

void Print(vector<int>& a){
 for(int x:a){
    cout << x << " ";
 }
 cout << endl;
}

int main(){
  cin >> h >> n;
  vector<vector<int>> mat(h,vector<int>(n,0)),sums(h,vector<int>(n,0));
  vector<vector<pii>> slivovi(h,vector<pii>(n,make_pair(0,0)));
  for(int i=0;i<h;++i){
    for(int j=0;j<n;++j){
       cin >> mat[i][j];
    }
    sums[i][0]=mat[i][0];
    for(int j=1;j<n;++j){
        sums[i][j]=sums[i][j-1]+mat[i][j];
    }
  }
  BuildSlivovi(slivovi,sums,mat);
  //Print(sums);
 // Print(slivovi);
  vector<int> nxtState(n,1);
  for(int i=0;i<h;++i){
    nxtState=NextState(nxtState,slivovi[i],i);
    //Print(nxtState);
  }
  Print(nxtState);

  return 0;
}