while True:
    try:
        n1, n2 = [int(x) for x in input().split(' ')]
        maze = []
        for i in range(n1+2):
            if i == 0 or i == n1+1:
                maze.append([1 for x in range(n2+2)])
            else:
                temp_lst = [int(x) for x in input().split(' ')]
                temp_lst.insert(0, 1)
                temp_lst.insert(n2+1, 1)
                maze.append(temp_lst)

        # print(maze)
        start = (1,1)
        end = (n1,n2)
        lst = [start]

        while lst:
            now = lst[-1]
        #     print(now)
            if now == end:
                for x in lst:
                    i, j = x
                    x = (i-1,j-1)
                    print('(%d,%d)'%(i-1,j-1))
                break

            row, col = now
            maze[row][col] = 2

            if maze[row - 1][col] == 0:
        #         print('up')
                lst.append((row - 1, col))
                continue
            elif maze[row + 1][col] == 0:
        #         print('down')
                lst.append((row + 1, col))
                continue   
            elif maze[row][col + 1] == 0:
        #         print('right')
                lst.append((row, col + 1))
                continue   
            elif maze[row][col - 1]==0:
        #         print('left')
                lst.append((row, col - 1))
                continue
            else:
                 lst.pop()
        else:
            print('This is a maza that can not be finished')
    except:
        break