#include <bits/stdc++.h>

using namespace std;

int main(){
 	int h,n;
 	cin>>h>>n;
 	int v[n][h];
 	int top[n];
 	for(int i =0; i<h;i++){
 		for(int j =0; j<n;j++){
 			
 			cin>>v[j][i];
 			v[j][i]--;
 			if(j>0&&v[j][i]<0){v[j][i]+=v[j-1][i];}
 			//initaize the top row to 1
 			top[j]=1;
		 }
	 }
	 /*
	 cout<<"!!!!!!!!!!!!!!!!!!"<<endl;
	 for(int i =0; i<h;i++){
 		for(int j =0; j<n;j++){
 			cout<<v[j][i]<<" ";
		 }
		 cout<<endl;
	 }
	 */
	 //first row(just the rest of the waterfall but we have an array for the top)
	
	 	for(int i =0; i<n;i++){ 
		 int j =-1;
 			//water just flows down
		 	if(v[i][0]>=0){
		 		v[i][0]+=top[i];
			 }
			
			 //theres a rock thats not the counting one
			// checking if we can check, if its a stone, and if its not the counting one
			 if(i<n-1&&v[i][0]<0&&v[i][0]>v[i+1][0]){
			 	
			 	top[i+1]+=top[i];
			 }
			 //theres a counting stone below
			 if(v[i][0]<0&&(i==n-1||v[i][0]<v[i+1][0])){
			 	// can we go left and/or right
			 	 
			 	//if we can both ways
			 	if(i+v[i][0]>=0&&i<n-1){
			 		
			 		//where does the remainder go???
			 		
			 	
			 		bool left = 1;
			 		bool right = ((j&1)+1)&1;
			 		bool rem  = top[i]&1;
			 		//add left side
			 		v[i+v[i][0]][0]+=top[i]/2+rem*left;
			 	
			 		//add right side
			 		v[i+1][0]+=top[i]/2+rem*right;
				 }
				 //can we go only right
				 else if(i<n-1){
				 	v[i+1][0]+=top[i];
				 }
				 //can we go only left
				 else{
				 	v[i+v[i][0]][0]+=top[i];
				 }
			}
		}
	
	 //rest of the waterfall
	for(int j =0; j<h-1;j++){
		int curStone= 0;
 		for(int i =0; i<n;i++){
 		
 			//water just flows down, they both need top be water(current and bottom)
		 	if(v[i][j+1]>=0&&v[i][j]>=0){
		 		v[i][j+1]+=v[i][j];
			 }
			 //theres a rock thats not the counting one
			// checking if we can check, if its a stone, and if its not the counting one, and if water is actually above
			 if(i<n-1&&v[i][j+1]<0&&v[i][j+1]>v[i+1][j+1]&&v[i][j]>0){
			 	
			 	curStone+=v[i][j];
			 
			 }
			 //theres a counting stone below
			 if(v[i][j+1]<0&&(i==n-1||v[i][j+1]<v[i+1][j+1])){
			 	//add current cell to curStone if its not a stone
			 	if(v[i][j]>0){curStone+=v[i][j];}
			 	// can we go left and/or right
			 
			 	//if we can both ways
			 	if(i+v[i][j+1]>=0&&i<n-1){
			 		
			 		//where does the remainder go???
			 		
			 		bool left = j&1;
			 		bool right = ((j&1)+1)&1;
			 		bool rem  = curStone&1;
			 		//add left side
			 		v[i+v[i][j+1]][j+1]+=(curStone/2)+(rem*left);
			 		//add right side
			 		//	cout<<"debug "<<i<<" "<<j<<" "<<curStone<<endl;
			 		v[i+1][j+1]+=(curStone/2)+(rem*right);
			 		
				 }
				 //can we go only right
				 else if(i<n-1){
				 	v[i+1][j+1]+=curStone;
				 }
				 
				 //can we go only left
				 else{
				 	v[i+v[i][j+1]][j+1]+=curStone;
				 }
				 curStone =0;
			 }
			 
		 }
	 }/*
	cout<<"!!!!!!!!!!!!!!!!!!"<<endl;
	 for(int i =0; i<h;i++){
 		for(int j =0; j<n;j++){
 			
 			cout<<v[j][i]<<" ";
		 }
		 cout<<endl;
	 }
	*/
	for(int i =0;i<n;i++){
		if(v[i][h-1]<0){v[i][h-1]=0;}
		cout<<v[i][h-1]<<" ";
	}
	return 0;
}