#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){
        if(Slivovi[i].f<0 || Slivovi[i].s>=n){cout << "Tu je error p " << idx << " " << i << endl;system("pause");}
        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(max(0,idx),min(n-1,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(max(0,idx1),min(n-1,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;
}

/*void MakeTestCases(){
   h=1000;n=1000;
   srand(time(false));
   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){
        mat[i][j]=rand()%2;
    }
   }
   BuildSlivovi(

}*/

double GetTime(){ return (double)clock()/CLOCKS_PER_SEC;}
double start_time,end_time,duration;
void Start(){ start_time=GetTime();}
void Stop(){ end_time=GetTime();duration=end_time-start_time;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  //h=100;n=10000;
  //Start();
  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)));
  srand(time(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);
  //Stop();
 // cout << duration << endl;

  return 0;
}