#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int row;
int col;
}CELL;
CELL hunt(int** map,int rowl,int rowr,int coll,int colr)
{
CELL a ;
int centerrow,centercol;
int newcoll,newcolr,newrowl,newrowr;
a.col =-1;
a.row=-1;
if(rowl <= rowr && coll <= colr)
{
centerrow =( rowl + rowr) / 2;
centercol=( coll + colr) / 2;
if(map[centerrow][centercol] == 0)
{
a.col = centerrow;
a.row = centercol;
return a;
}
if(map[centerrow][centercol] < map[centerrow][centercol - 1])
{
newcoll = centercol + 1;
newcolr = colr;
}
else
{
newcoll = coll;
newcolr = centercol - 1;
}
if(map[centerrow][centercol] < map[centerrow - 1][centercol])
{
newrowl = centerrow + 1;
newrowr = rowr;
}
else
{
newrowl = rowl;
newrowr = centerrow - 1;
return hunt(map,newrowl,newrowr,newcoll,newcolr);
}
return a;
}
}
int main()
{
CELL des;
int** map;
int i,j;
int m,n;
scanf("%d %d",&m,&n);
while(m > 0 && n > 0)
{
map = (int**)malloc(sizeof(int*)*m);
if(map == NULL)
{
printf("Out of memorg!\n");
return 0;
}
for(i = 0;i < m;i++)
for(j = 0;j < n;j++)
scanf("%d",&map[i][j]);
des = hunt(map ,0,m-1,0,n-1);
printf("%d %d",des.col,des.row);
return 0;
}
}