import sys class MazeCracker(): def __init__(self, row, column, matrix): self.row = row self.colum = column self.matrix = matrix self.result = [[0, 0]] self.current_x = 0 self.current_y = 0 def confict(self): if self.matrix[self.current_x][self.current_y] == 1: return True return False def find_way(self): if self.current_x == self.row -1 and self.current_y == self.colum - 1: for i in self.result: print('({},{})'.format(*i)) return for x, y in [[0, 1], [1, 0]]: self.current_x += x self.current_y += y if self.current_x > self.row - 1&nbs***bsp;self.current_y > self.colum - 1: self.current_x -= x self.current_y -= y continue self.result.append([self.current_x, self.current_y]) if not self.confict(): self.find_way() self.result.pop() self.current_x -= x self.current_y -= y def main(): while True: matrix_info = sys.stdin.readline().strip() if matrix_info == '': break row, colum = matrix_info.split() matrix = [] for i in range(int(row)): matrix.append(list(map(int,sys.stdin.readline().strip().split()))) maze_instance = MazeCracker(int(row), int(colum), matrix) maze_instance.find_way() if __name__ == '__main__': main()