#include<iostream>#include<vector>usingnamespace std;
vector<int>findBall(vector<vector<int>>& grid){int n = grid[0].size();int m = grid.size();
vector<int>res(n);for(int j =0; j < n; j++){int col = j;// 记录刚开始小球位于第几列for(int i =0; i < m; i++){int dir = grid[i][col];
col += dir;if(col <0|| col == n || grid[i][col]!= dir){
col =-1;break;}}
res[j]= col;}return res;}intmain(){
vector<int> res;int m, n;
cin>>m>>n;
vector<vector<int>>grid(m,vector<int>(n,0));for(int i =0; i < m; i++){for(int j =0; j < n; j++){
cin>>grid[i][j];}}
res =findBall(grid);for(int i =0; i < res.size(); i++){
cout<<res[i]<<" ";}return0;}